Playing with shaders, preventing aliasing-effects
I was coding patterns using openGL and GLSL shaders, and decided to show the importance of keeping aliasing effect in mind.
In figure 1 aliasing effects can clearly be seen, the borders of the stripes does not look sharp at all points, this is due to aliasing effect .
These usually ugly unwanted effects can usually be avoided, or at least decreased.
By smoothing out the edges a little bit at rendering time a more pleasant result can be obtained (figure 2), and that will also decrease the need of multisampling to get rid of the aliasing-effect.
I smoothed out the edges of the stripes by using in the built-in GLSL function smoothstep in the transition between the background and stripe edge.
| Figure 1. Stripes with alising.
|| Figure 2. Stripes with less alising effects.
Figure 3. Screenshot of the shader. Changing color and moving around over time.