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?

  • \$\begingroup\$ It seems okay to me, but why don't you try? \$\endgroup\$ May 16, 2014 at 14:36
  • \$\begingroup\$ 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). \$\endgroup\$
    – GuyRT
    May 16, 2014 at 14:47
  • \$\begingroup\$ It's not working; I thought this was a potential problem but I suppose now it isn't. \$\endgroup\$ May 16, 2014 at 15:12

1 Answer 1


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.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .