Is there any fast(for performance) way to detect in glsl if fragment has been multisampled, but in second(light) pass using textures where been 1st pass rendered. Or how is opengl storing informations about multisampling?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
They are several. The usual one is to check is the current’s coordinates (gl_FragCoord) are (0.5, 0.5). If it is, it means that you’re in the middle of a polygon : it’s sampled only once.
It it’s not, it’s probably one of the 4 (for 4xMSAA) rotated-square-corners : You’re on an edge, and openGL has detected that one sample only isn’t enough.
See also http://www.opengl.org/pipeline/article/vol003_6/
In order to have this information in a second pass, you’ll have to store it in a g-buffer, though.
EDIT : Here is a code snippet that I’ve just done. Tested on gtx 470 with a 1024×1024 4xMSAA texture.
Vertex shader :
Fragment shader :
Edges are green, center of polygon is red.
For your original question, I recommend you this article : http://www.gamasutra.com/view/feature/3591/resolve_your_resolves.php