Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: question about 4 x MSAA

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2018
    Posts
    8

    question about 4 x MSAA

    Hello, I have a question about 4 x MSAA with Opengl:

    Assume, I draw a white ( 1, 1, 1, 1 ) quad on a black background (0, 0, 0, 1) using 4 x MSAA.
    A pixel is covered by the quad by 100% in y direction and by 70% in x direction.
    Should the resulting pixel have a color of ( 0.7, 0.7, 0.7, 1 ) ?

    Regards

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,007
    4x MSAA only has four samples per fragment, so the blending ratios will be in increments of 25%. So 0.7 isn't possible. Also, the alignment matters, so 70% coverage might have 2 or 3 samples inside depending upon the sample positions.

    So you'd expect to get either (0.5,0.5,0.5,1) or (0.75,0.75,0.75,1). It's theoretically possible to get other values, as the sample positions are up to the implementation. Having all 4 samples inside 70% coverage seems quite unlikely but not entirely beyond the bounds of possibility; but only having one is inconceivable.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2018
    Posts
    8
    I see. Would it be possible to calculate the blending ratio by other means, like, in the shader, in cases where I can calculate it exactly ( like screen space quad drawing )?

    Also if you could point me to a document that defines exactly how the samples are spatially distributed over the pixel and which sample yields which blending ration I'd be grateful.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,007
    Quote Originally Posted by Desperado View Post
    I see. Would it be possible to calculate the blending ratio by other means, like, in the shader, in cases where I can calculate it exactly ( like screen space quad drawing )?
    Rather than using MSAA, you can use glEnable(GL_POLYGON_SMOOTH) to generate alpha values for edge fragments, which can then be used with blending. However, this requires rendering polygons in front-to-back order, and it only considers polygon edges, not e.g. depth testing.

    Quote Originally Posted by Desperado View Post
    Also if you could point me to a document that defines exactly how the samples are spatially distributed over the pixel and which sample yields which blending ration I'd be grateful.
    The sample points are implementation-dependent. You need to refer to the vendor's documentation for your particular hardware, or you can use glGetMultisample() to query the sample locations at run time (if they're fixed; it's possible for the sample locations to vary between fragments).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •