Im trying to understand how a fragment shader is invoked during a multisampled rendering, Ive carefully read the specs but Im a bit confused..
I setup a multisampled FBO with a color and a depth/stencil renderbuffers.. fine
I setup a simple 1-line vertex shader just for transform and another 1-line fragment shader which just returns a black color.. and its fine
I draw a line - the line is displayed smoothed.. fine
now, If in the fragment shader, instead of dumbly returning a black color, I texelFetch from a multisampled texture, always reading sample number 0 (that is, black), I get a jagged line..
whats the difference between a simple myoutcolor=vec4(0.0)
and a myoutcolor=texelFetch(mysampler2DMS,...,0)
?
the specs state that a fragment shader is executed at sample-level only if it statically uses gl_SampleID
, gl_Samplemask[]
, or has a "sample" storage qualifiers.. (in all these cases this means GLSL #version 400
or above), otherwise it gets executed at fragment level..
but how can that be? in the above example, I got a smoothed line even if I always returned the same color, so I tought the fragment shader was ALWAYS executed at sample level in a multisampled framebuffer.. on the other hand, if it was not the case, I should get smooth results even if returning always the same sample from a MS texture..
can somebody help me figure this out?
PS: Im currently using #version 330, but I found that every multisampling-aware statement Id need to correctly handle MS (gl_SampleID
, gl_Samplemask[]
, sample..) is only supported in GLSL 400 or above.. so, whats exactly the support GLSL 330 offer for correctly handling multisampling? how can I handle MS textures in GLSL 330?