title: How does multisample really work?
body: <p>I am very interested in understanding how multisampling works. I have found a large literature on how to enable or use it, but very little information concerning what it really does in order to achieve an antialiased rendering. What I have found, in many places, is conflicting information that only confused me more.</p>
  
  <p>Please note that <strong>I know how to enable and use multisampling</strong> (I actually already use it), what I don't know is what kind of data really gets into the multisampled renderbuffers/textures, and how this data is used in the rendering pipeline.</p>
  
  <p>I can understand very well how supersampling works, but multisampling still has some obscure areas that I would like to understand. </p>
  
  <p>here is what the specs say: (OpenGL 4.2)</p>
  
  <blockquote>
    <p>Pixel sample values, including color, depth, and stencil values, are stored in this
    buffer (the multisample buffer). Samples contain separate color values for each fragment color.</p>
    
    <p>...</p>
    
    <p>During multisample rendering the contents of a pixel fragment are changed
    in two ways. First, each fragment includes a coverage value with SAMPLES bits.</p>
    
    <p>...</p>
    
    <p>Second, each fragment includes SAMPLES depth values and sets of associated
    data, instead of the single depth value and set of associated data that is maintained
    in single-sample rendering mode.</p>
  </blockquote>
  
  <p>So, each sample contains a distinct color, coverage bit, and depth. What's the difference from a normal supersampling? Seems like a "weighted" supersampling to me, where each final pixel value is determined by the coverage value of its samples instead of a simple average, but I am very unsure about this. And what about texture coordinates at sample level?</p>
  
  <p>If I store, say, normals in a RGBF multisampled texture, will I read them back "antialiased" (that is, approaching 0) on the edges of a polygon?</p>
  
  <p>A fragment shader is called once per fragment, unless it uses gl_SampleID, glSampleIn or has a 'sample' storage qualifier. How can a fragment shader be invoked once per fragment and get an antialiased rendering?</p>