Hi,
The position reconstruction is currently working but I want to change it.
I'm using linear depth, so I can easly get an "eye ray" and use it to recostruct the position.
It works for directional lights and point lights if drawn by a fullscreen quad + scissor test. However I want to change the scissor-test-based point light into sphere geometry drawing.
The main problem is that the directional light pass is still drawn by a fullscreen quad and the two different approaches need two different depth value.
Now I'm storing the depth value as (ViewPos.z / FarPlane). It works perfectly if I'm drawing a fullscreen quad in the following way:
- compute view rays from the 4 corner of the far plane
- in the lighting pass simply get the necessary ray and compute world position:
vec3 wPosition = eyePosition + EyeRay * depthVal;
However, if I'd like to draw point lights with sphere, I cannot use the view rays to the far plane. I can only use the world position of the vertex of the sphere then compute a view ray from it. But it's trivial that the depth required to reconstruct world position is not ViewPos.z. It needs length(ViewPos).
I want to use linear depth so I don't want to reconstruct position using the inverseViewProj matrix.
Why I need geometry? For spot lights also + performance.