How to never draw "Jaggies" in the first place considering resolution and scale Ok, I have a simulation I am trying to make. The entire simulation is drawn by circles (with gl_Point) and rectangles (gl_triangles with indices).

It would be great to add some anti aliasing especially as there scale is usually rather small.

My problem is I have seen some formulas that smooth step the edges of a shape, however I do not know how to properly consider scale.

Each sprite will have different scale to it, each rectangle will have a different width / height ratio, not to mention I am not yet passing in texture coords because they have been so far un-necesary. And this will run on multiple screen resolutions.

I guess I have two questions:


Is it possible to anti-alias a rectangle in a fragment shader without knowing the UV of each fragment since I am not yet passing them in? Even if it was possible how would I account for different ratios of rectangles?
What math can I use to ensure that no matter the device resolution, or shape size that the anti aliasing effects a maximum of 2 pixels (or whatever) from the edge of the shape?
Well you can render at higher resolution and sample down thhis is called FSAA and should just work without much change to render code. FSAA has the benefit of not having a conflation problem whereas smoothing does.


No, something has to emit this info.
You take the derivate (the gfx card does this for you) of the surface varying to determine how far the step would take you in your pixel. if its over the edge then you antialias.