Alpha to coverage vs alpha test

I try replace my alpha test by an alpha to coverage… however the fellowing picture show the result.

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…


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 :slight_smile:
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.

Extrally… but is there any way to setup the alpha to coverage to get the same behavior?

You can set GL_SAMPLE_COVERAGE_INVERT to true using the glSampleCoverage function.


That’s actually what I had done but I have the same result… :stuck_out_tongue: That’s where can my misunderstanding of glSampleCoverage…

I went over the specs again and it looks like I was wrong also…


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.


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!