View Full Version : Transparency in fragment program?

07-02-2005, 04:36 AM
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:

SUBC tmp.x, val1, val2
MOV frag_color.a, 0.0;


MOV result.color, frag_color;


Matt Zamborsky
07-02-2005, 06:18 AM
You must enable alpha test in program :)

07-02-2005, 06:26 AM
Originally posted by Matt Zamborsky:
You must enable alpha test in program :) You mean glEnable(GL_ALPHA_TEST)?
I'll test it. Thanks

07-02-2005, 06:53 AM
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...

07-02-2005, 07:13 AM
Why not just kill the fragment? With ARB_fragment_program there is the KIL instruction...

07-02-2005, 08:10 AM
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...

07-02-2005, 10:05 AM
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.


Matt Zamborsky
07-04-2005, 11:30 PM
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.

07-05-2005, 08:09 AM
Originally posted by Matt Zamborsky:
I get about 20% speed up with classic alpha test instead KILL instruction.Interesting. On what kind of hardware?

Matt Zamborsky
07-08-2005, 12:38 PM
256bit NV35 revision A1 with 128 MB DDR.

07-09-2005, 04:25 AM
Thank you, I hope they fixed this up with NV4x. Maybe I'll try a simple test in the next few days.