<p>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.</p>

<ol>
<li><p>No, something has to emit this info.</p></li>
<li><p>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.</p></li>
</ol>

CC BY-SA 3.0
2016-07-07T20:22:03.073Z
How much higher resolution should I upscale it
J.Doe
CC BY-SA 3.0
2016-07-07T20:24:11.140Z
Usually 4 is fine but read this first https://www.opengl.org/wiki/Multisampling you dont actually need to store those extra pixels
joojaa
CC BY-SA 3.0
2016-07-07T23:36:25.307Z
I hope that is compatible with opengl es 2.0. It seems almost nothing is. My fear is that my app uses an accumulation buffer so I never clear the buffer that is drawn on, i simply fade it then draw a new frame. Oviously a bigger FBO means slower loading time. Hopefully the extension is supported making that a non issue.
J.Doe
CC BY-SA 3.0
2016-07-07T20:16:03.360Z
2016-07-07T20:16:03.360Z
joojaa
<p>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).</p>

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

<p>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.</p>

<p>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.</p>

<p>I guess I have two questions:</p>

<ol>
<li>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?</li>
<li>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?</li>
</ol>

<line-drawing><antialiasing>
How to never draw "Jaggies" in the first place considering resolution and scale
J.Doe
# How to never draw "Jaggies" in the first place considering resolution and scale

(Asked by: username_0 on 2016-07-07)

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:

1. 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?
2. 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?

**Tags:** line-drawing, antialiasing


---

## 1 answers

### Answer by username_1 on 2016-07-07. Score: 4 | Accepted answer

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.

1. No, something has to emit this info.
2. 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.

> **Comments:**
> **username_0**: How much higher resolution should I upscale it  
> **username_1**: Usually 4 is fine but read this first https://www.opengl.org/wiki/Multisampling you dont actually need to store those extra pixels  
> **username_0**: I hope that is compatible with opengl es 2.0. It seems almost nothing is. My fear is that my app uses an accumulation buffer so I never clear the buffer that is drawn on, i simply fade it then draw a new frame. Oviously a bigger FBO means slower loading time. Hopefully the extension is supported making that a non issue.  

---

