# Deferred lighting and point light volumes

I'm doing deferred point light shadow mapping and I am drawing my point lights using light volumes. Normally I access the position/diffuse texture/normals using this in the fragment shaders:

vec2 texcoord = gl_FragCoord.xy / UnifPointLightPass.mScreenSize;

vec3 worldPos = texture(unifPositionTexture, texcoord).xyz;
vec3 normal   = texture(unifNormalTexture, texcoord).xyz;
vec3 diffuse  = texture(unifDiffuseTexture, texcoord).xyz;


When doing directional lights, I just draw a fullscreen-rectangle, but when doing point lights I use light volumes - drawing a 3d sphere from the cameras point of view to limit the amount of fragments processed.

Does light volumes change the way I get the texcoord?

• It seems okay to me, but why don't you try? – János Turánszki May 16 '14 at 14:36
• Looks OK. Is it working? One thing to be careful of is when the camera is inside the light volume (to be more accurate - when the light volume is clipped by the near plane). You then either have to "cap" the volume or draw the back faces of the sphere (and reverse the direction of the depth test). – GuyRT May 16 '14 at 14:47
• It's not working; I thought this was a potential problem but I suppose now it isn't. – KaiserJohaan May 16 '14 at 15:12

gl_FragCoord.xy just gives you the pixel coordinates where this instance of the shader is running, so getting the texture coordinate for full-screen textures this way should work fine regardless of what kind of geometry you're rendering - a full-screen rectangle or 3D light volume geometry.