Sign in to follow this  

discard statement (cg)

This topic is 3625 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently experimenting with the discard statement of cg in a fragment shader and i'm not sure if I understand the the operation correctly. Is it the correct behaviour, that the value currently in the framebuffer is cleared? If so, is there a possibility that only the output of the shader is suppressed without changing the framebuffer? Thanks in advance, Poons

Share this post


Link to post
Share on other sites
The value will not be cleared. When you say discard in your pixel shader it will not write to frame buffer. So if you first render blue pixel and then start rendering red one but call discard the only thing you'll see is blue pixel. :)

Share this post


Link to post
Share on other sites
Thats good to hear. However, in my case the blue pixel rendered before is replaced with the opengl clear color if I discard a fragment.

This is my fragment shader code:

if (tex2D(alphaMask, texCoord).a > 0.5)
discard;

oColor.rgb = depth;


Any ideas? Btw, I'm rendering to an FBO. Thanks for your help.

Share this post


Link to post
Share on other sites

This topic is 3625 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this