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 ?
diffuse = texelFetch(...);
(do some math here, but do not use 'diffuse' variable)
specular = texelFetch(...);
(math again, assume that 'diffuse' is ready, but do not use 'specular')
...
For me this trick boosted performance about 1.5x (I had 14 texelFetches in shader)
Look like trying to re-arrange texleFetch call doesn’t help much in my code.
May be its because the lighting code is so simple that it doesn’t matter when to call texelFetch.
Try running my unoptimized MSAA deferred shading code on my brother’s NVIDIA 9800GT give me a surprise.
when not using AA the result are roughly the same as my HD4670
but when using MSAA the performance are so much better than my 4670.
this is a result of rendering a scene with following configuration
If texelFetch performance on both NVIDIA and ATI are the same,It look like even
nonexpensive (once) highend lastgen card can handle MSAA deferred shading very well.
Would like to try this on a newer ATI card.
Can someone suggest me ATI card that equivalant to 9800gt.
hope this help other people who want to try implementing MSAA deferred shading.
I (wildly) speculate that on GeForce, the subpixels are different layers (something like texture_array_2d); while on Radeons they are contiguous in VRAM. Basing my speculations on notes from many sources that the cards handle/manage MSAA completely differently; and having met the same nice performance puzzles on GeForces.
As a side note, the above code IME decreases performance on GeForces. (reason: decreases max possible # of warps, by using too many registers, and doesn’t interleave ALU and TEX operations)