Some outputs of pixel shaders not being antialiased

Started by
3 comments, last by Nik02 18 years, 8 months ago
I wrote a quick cartoon pixel shader. Here's the lighting lines:
if(dot(iNormal,normalize(LightDirection))>0)
	oColor=float4(0.5,0.5,0.5,1);
else
	oColor=float4(1,1,1,1);
Something weird happens. I have antialiasing forced on in my video card drivers, and everything is antialiased just fine - except for the border between the light and dark sides of the objects that use this antialiasing shader. It's a jagged and sharp border. Is there any reason why this happens? Why would everything else be antialiased except this? I've seen pixel shaders that use a texture lookup instead of something like this code, and I suppose this is why, although I can't figure out why the border between light and dark isn't being antialiased!
_______________________________________________________________________Hoo-rah.
Advertisement
The normal supersampling algorithm only considers the edges of the polygons - because the texture filtering automatically handles the "antialiasing" of polygon innards. Using supersampling, the pixel shaders are still executed per-pixel instead of per-fragment, thus not antialiasing the shader result automatically.

The newer pixel shader profiles support per-pixel derivatives of the texture coordinates in screen space. You can use them to perform accurate filtering at the shader yourself, at the cost of more complex shader.

Finally, when using true multisampling, each pixel actually correspond with more than one fragment, so you get automatically antialiased pixel shaders at the cost of more memory and fillrate. You can't usually force this mode from the drivers, so you'll need to use the appropriate presentation parameters if you want to use this approach.

Niko Suni

Ahh, that's it. Thanks for the info :)
_______________________________________________________________________Hoo-rah.
You have confused super and multi-sampling. Super sampling runs your shader multiple times per final screen pixel, and not used too often nowadays.

Multisample only handles external polygon edges, and runs your shader once per final screen pixel.
Quote:Original post by SimmerD
You have confused super and multi-sampling. Super sampling runs your shader multiple times per final screen pixel, and not used too often nowadays.

Multisample only handles external polygon edges, and runs your shader once per final screen pixel.


Yea, I accidentally mixed up the terms. Sorry for that, otherwise the info should be correct [smile]

Niko Suni

This topic is closed to new replies.

Advertisement