I have implemented MSAA in deferred shading by calculate lighting at every sample of the pixel and then average it,something like this
Code :vec4 pixelIntenisty = vec4(0.0,0.0,0.0,0.0); for(int i=0;i<MSAACount;i++){ float depth = texelFetch(depthTextureMSAA,texCoord,i); vec4 diffuse = texelFetch(diffuseTextureMSAA,texCoord,i); vec4 specular = texelFetch(specularTextureMSAA,texCoord,i); vec4 normal = textelFetch(normalTextureMSAA,texCoord,i); //calculate lighting pixelIntenisty += calculateLighting(......); } //average the pixel intensity pixelIntensity = pixelIntensity/MSAACount;
while this give a good result ,the performane is totally killed.
so , I am thinking about doing antialiasing only at the edge pixel but that will also invole some kind of edge detection and stencil operation to mark the pixel(which might make thing even more slower).
Is there any other approch (in OpenGL 3.2-3.3 compatible way) to handle real antialiasing in deferred shader ?
Cheer
somboon



