Jump to content
  • Advertisement
Sign in to follow this  
Zische

"if" in cg fragment shader goes nuts

This topic is 4832 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 have a radeon 9800 pro from sapphire. the function from the cg library cgGLGetLatestProfile(CG_GL_FRAGMENT) returns CG_PROFILE_ARBFP1. in a fragment program i have following condition: float test = 5.0; if(test<0) discard; the fragment is discarded. why is that? i thought all advanced profiles support "if"

Share this post


Link to post
Share on other sites
Advertisement
this is just a guess about cg but check if there are preprocessors such as OPTION that you should include to force a certain profile.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zische
i have a radeon 9800 pro from sapphire.
the function from the cg library cgGLGetLatestProfile(CG_GL_FRAGMENT) returns CG_PROFILE_ARBFP1.
in a fragment program i have following condition:

float test = 5.0;
if(test<0) discard;

the fragment is discarded. why is that? i thought all advanced profiles support "if"


what is fragment_program 1.0?

pixel_shader 1.0 didn t support conditionals although i am not sure what FP1 is so maybe check out the arb extention registry and look up what version of ps it used

Share this post


Link to post
Share on other sites
Quote:

the fragment is discarded. why is that? i thought all advanced profiles support "if"

SM2.0 (or its OpenGL equivalent) doesn't support dynamic branching.
It does support static branching, but that's only useful in some cases.

Share this post


Link to post
Share on other sites
I could also be that the compiler knows it will never be < 0 since you are setting it to 5.0f. I have seen many assumptions that shader compilers make. Since from the code you posted above this line could never be true, it may ommit the line. Did you already try replacing it with a variable to see if the code changes. Rather than using a static number?

[Edited by - Matsy on August 26, 2005 9:28:00 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!