View Full Version : I only want to discard the depth component, not the color

10-17-2007, 05:01 PM
I have a wall texture with a window in it. I would like to discard the depth component of the pixels of the texture that are below 0.5. Is this possible?

The purpose of this is to allow coronas to shine through windows.

10-17-2007, 06:29 PM
You can't discard a depth component. If you want it to always fail, then set it to a number as close as you dare to the near plane.

10-17-2007, 07:07 PM
I'll file this under "if only".

10-17-2007, 07:41 PM
You mean the far plane, don't you? How can I change the depth value in a frag program?

10-17-2007, 07:48 PM
gl_FragDepth = gl_FragCoord.z + delta ; // delta= 0 by default

10-18-2007, 11:10 AM
So to "dismiss" the depth:

if something
gl_FragDepth = 1.0;


10-18-2007, 12:39 PM
Modifying depth so the depth test fails will also kill any color output. It sort of just ends up being a more inefficient alpha-test. I'm afraid there's no way to do what you want, other than separating the window part from the rest of the texture and draw that with glDepthMask(GL_FALSE);

10-18-2007, 12:56 PM
Ah, I forgot about that.

Oh well, it wasn't important.