PDA

View Full Version : Alpha to coverage vs alpha test



Groovounet
01-21-2008, 05:09 AM
I try replace my alpha test by an alpha to coverage... however the fellowing picture show the result.

http://img147.imageshack.us/img147/9573/bugantialiasingpc9.png

With alpha test I use the setup it as glAlphaFunc(GL_LESS, 1.0);

It seams that this function doesn't apply on alpha to coverage. How are we supose to do this setup for alpha to coverage ? I had a quick look on glCoverageSample but I haven't seen any differences ... actually I not sure I have understood the purpose of this function...

Thanks!

skynet
01-21-2008, 05:26 AM
With alpha test I use the setup it as glAlphaFunc(GL_LESS, 1.0);

So, your alpha channel is < 1.0 wherever your leaf-texture should be visible and it is 1 wherever the alpha test should fail? This explains what you get :-)
Since the leaf itself probably has an alpha value of 0.0, its coverage will be 0.0 --> it won't ouput any fragments. And the outside of the leaf has a value of 1.0, thus it will get drawn.

Groovounet
01-21-2008, 06:20 AM
Extrally... but is there any way to setup the alpha to coverage to get the same behavior?

-NiCo-
01-21-2008, 06:25 AM
You can set GL_SAMPLE_COVERAGE_INVERT to true using the glSampleCoverage function.

N.

Groovounet
01-21-2008, 07:18 AM
That's actually what I had done but I have the same result... :p That's where can my misunderstanding of glSampleCoverage...

-NiCo-
01-21-2008, 07:32 AM
I went over the specs again and it looks like I was wrong also...


If
SAMPLE COVERAGE INVERT is TRUE, the temporary coverage is inverted (all bit
values are inverted) before it is ANDed with the fragment coverage.


It's the temporary value that's getting inverted, not the resulting one.

I think you're better of inverting the alpha values in the fragment shader yourself.

N.

Groovounet
01-21-2008, 12:21 PM
I finally choose to change the value of my alpha channel to have 1.0 means opaque and 0.0 transparent. Work like a charm indeed.

Thank anyway!