Transparency in fragment program?

Hi
Depending on some properties, I want to set a fragment to invisible.
To do that, I set the alpha value to 0. But it doesn’t work. Why? Do I have to set special properties?

My pseudocode:
[i]
SUBC tmp.x, val1, val2
IF GT.x
MOV frag_color.a, 0.0;
ENDIF

MOV result.color, frag_color;[/i]

Thanks

You must enable alpha test in program :slight_smile:

Originally posted by Matt Zamborsky:
You must enable alpha test in program :slight_smile:
You mean glEnable(GL_ALPHA_TEST)?
I’ll test it. Thanks

No… it doesn’t work.
I have glEnable(GL_DEPTH_TEST) and glEnable(GL_ALPHA_TEST),but things are still not tranpsarent.
But it works with glEnable(GL_BLEND) and glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA).
But I don’t want to use blending…

Why not just kill the fragment? With ARB_fragment_program there is the KIL instruction…

Because the alpha test is one of the first operation to be done and I didn’t find any precise information about KIL.
I need the fastest way of “disable/kill” a fragment. And set the alpha value to zero seem to be the fastest. But if somebody has any information about it…
Thanks

For alpha-test to work, you also need to set the correct alpha-function.

glEnable (GL_ALPHA_TEST);
glAlphaFunc (GL_GREATER, 0.1f);

This means only fragments with an alpha-value greater than 0.1f will pass the test.
If you don’t specify the alpha-function, it might be some default function like GL_ALWAYS and hence will not work.

Jan.

Jan is right, you must set the correct alpha function.

Dont use the KILL instruction to alpha test(if you have opportunity). I get about 20% speed up with classic alpha test instead KILL instruction.

Originally posted by Matt Zamborsky:
I get about 20% speed up with classic alpha test instead KILL instruction.
Interesting. On what kind of hardware?

256bit NV35 revision A1 with 128 MB DDR.

Thank you, I hope they fixed this up with NV4x. Maybe I’ll try a simple test in the next few days.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.