PDA

View Full Version : Transparency in fragment program?



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

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

...

MOV result.color, frag_color;

Thanks

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

Lapinot
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

Lapinot
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...

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

Lapinot
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...
Thanks

Jan
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.

Jan.

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.

Obli
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.

Obli
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.