PDA

View Full Version : Multisampling with triangles sharing the edge



debonair
04-20-2015, 03:48 PM
According to my understanding:

Multisampling: Consider we have primitive with 4X multisampling and only 1 sample is covered by primitive. So it calculates the percentage (pixel coverage based on how many samples passed the test) i.e. 25% and blends with the background color and we get blended color for that pixel which is copied to all the 4 samples when fragment shader is executed.

Antialiasing: OpenGL calculates the amount of a pixel that is covered by a primitive (point, line, or triangle) and uses it to generate an alpha value for each fragment. This alpha value is multiplied by the alpha value of the fragment produced by your shader and so has an effect on blending when either the source or destination blend factor includes the source alpha term.

Please correct me it is wrong.

In case of multisampling we get 50-50 blend but with anti-aliasing we get 25-25-50 blend, hows that?

In case of multisampling when we render one triangle it will update the FBO with 25-75 pixel color and when second triangle being rendered it will blend with the background color, so we should get background color instead of 50-50, but this is not the case.

Here by multisampling, I meant to say enabling it with glEnable(GL_MULTISAMPLE) and by antialiasing, i meant enabling it with GL_POLYGON_SMOOTH

Alfonse Reinheart
04-20-2015, 06:16 PM
I can't speak to what polygon smoothing does, but I can correct your ideas about multisampling antialising:


Multisampling: Consider we have primitive with 4X multisampling and only 1 sample is covered by primitive. So it calculates which samples in that pixel are covered by the fragment generated by the primitive. This information is stored with the fragment. When the fragment's colors are written to the framebuffer, they are only written to the samples within that pixel that correspond to the samples covered by the fragment.

When a multisample framebuffer is resolved, this means that the system goes to each pixel in the framebuffer. It then blends all of the sample colors in that pixel together to compute the final color.