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?