Hard edges with if statements

hey all

when writing pixel shaders with if statements on the current co-ords
(e.g. if (PosW.x>0) col.a=0) then i get a hard edge which won’t anti-alias
anyone got any ideas of how to get around this (without replacing if statement with a smooth function?)

there is no easy solution. as the pixelsahder code is executed for single pixels, a pixel is either in the range or not. writing a smooth function is one way, another would be to calculate the state of the neighbour pixels and do an interpolation or messing around with the ddx and ddy functions…

…or you calc the whole thing in a higher resolution and scale it down after…

i guess filter kernel operations are what you looking for.(eg for a smoothing function) so you caclculate your operation for a matrix of pixels around your point of interest. if you want to magnify egdes youll need something like a highpass filter. i think there are some shaders around using that kind of technique.

take a look here: http://www.cs.washington.edu/research/metip/tutor/tutor.html

thanks for the replies
so does anti-aliasing only run at the rasterising stage then?
I think i’ll probably go for a smoothstep function linked to ddx/y
bah, no easy way out!

yes, anti-aliasing works only on geometry edges…