Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Working of alpha to coverage

I have question about the working of alpha to coverage. Coverage value specifies that which samples of a pixels are covered by the primitive. with alpha to coverage, we AND alpha value with coverage value of the pixel to determine the final coverage. Now Superbible specifies that "if 66% of the pixel is covered by the primitive and alpha value is 40% then final coverage value would be 60 x 40 % which is 25% and for 8 sample buffer, 2 samples will be covered." But how does it work at sample level.? and how does it determine which samples to cover out of 8?

if the coverage is a bit field for each sample then how does AND operation is performed for each sample ?

like image 994
debonair Avatar asked Sep 15 '25 20:09

debonair


1 Answers

But how does it work at sample level.? and how does it determine which samples to cover out of 8?

This is completely up to the implementation. If the aplha is 0.5, then GL_SAMPLE_ALPHA_TO_COVERAGE will just create a coverage mask with half of the available bits set (think of dithering).

What the GL spec actually requires is just (quoting section 17.3.3. of the GL 4.5 core profile spec):

No specific algorithm is required for converting the sample alpha values to a temporary coverage value. It is intended that the number of 1’s in the temporary coverage be proportional to the set of alpha values for the fragment, with all 1’s corresponding to the maximum of all alpha values, and all 0’s corresponding to all alpha values being 0. The alpha values used to generate a coverage value are clamped to the range [0; 1]. It is also intended that the algorithm be pseudo-random in nature, to avoid image artifacts due to regular coverage sample locations. The algorithm can and probably should be different at different pixel locations. If it does differ, it should be defined relative to window, not screen, coordinates, so that rendering results are invariant with respect to window position.

You next question is then very simple to answer:

if the coverage is a bit field for each sample then how does AND operation is performed for each sample ?

The AND operation is applied to the temporary coverage mask created by GL_SAMPLE_ALPHA_TO_COVERAGE and the fragments coverage mask as created by the coverage samples.

like image 120
derhass Avatar answered Sep 17 '25 20:09

derhass