Original Post
Hi guys! I have a small problem with my deferred shading implementation... in a nutshell, I'm rendering some point lights, but they continue to move with the camera :S In my G-Buffer, the depth is computed this way: output.Depth = ( viewPosition.z - nearZ ) / ( farZ - nearZ ); then in the light vertex shader I compute the view direction from the frustum corners (rendering a full screen quad): cornerFrustrum is a vector3 created this way: finally, I compute the position in the pixel shader this way: but as I said, the lights continue moving with the camera :( If I remove the multiplication in the VS with InvertedViewMatrix, the lights are correct but they disappear if I move a bit far from their position... Any suggestions?
float3 corner = float3(-cornerFrustrum.x * input.Position.x, cornerFrustrum.y * input.Position.y, cornerFrustrum.z);
output.viewDirection = mul(float4(corner,1), InvertedViewMatrix);
float farY = (float)Math.Tan(Math.PI / 3.0 / 2.0) * CameraManager.ActiveCamera.Far;
float farX = farY * CameraManager.ActiveCamera.AspectRatio;
Vector3 frustrumCorner = new Vector3(farX, farY, CameraManager.ActiveCamera.Far);
float depthVal = tex2D(depthSampler, input.TexCoord).r;
float3 position = cameraPosition + input.viewDirection * depthVal;