PDA

View Full Version : gl_ClipDistance read in fragment shader



Yandersen
08-31-2014, 08:58 AM
I have a Q regarding the clipping against custom clipping planes. I write gl_ClipDistance[0] in the vertex shader to clip the geometry behind the camera (I need it because I write the gl_FragDepth in fragment shader which prevents the clipping for Zc). But when does the clipping actually occurs - after the fragment shader executes or the execution does not occur for the clipped fragments at all? If I read the interpolated value of gl_ClipDistance[0] in fragment shader - does it change the clipping behavior (so the FS executes even for clipped fragments)? Does it makes sense at all to use clipping plane for the geometry behind camera in case gl_FragDepth is calculated manually?

Firadeoclus
09-01-2014, 05:40 AM
Clipping occurs before rasterisation, clipped geometry doesn't generate fragments. Reading gl_ClipDistance in the fragment shader does not change this.

Yandersen
09-01-2014, 01:46 PM
Thank you! :)