On a blue canvas, a quadrilateral is drawn below with a WebGL fragment shader that calculates the pixel intensity with a sin function whose wavelength (as pixels per cycle) is controlled by the slider. The quad is 400 pixels wide.
Pixels Per Cycle
≥ 2, the texture renders without aliasing and looks "good".
Pixels Per Cycle
< 2, the
sin functions frequency is much too high to be captured by
the 400 pixel width of the quadtrilateral. Instead, the texture
appears to have a frequency much lower than the mathematical
frequency ( Cycles Per Pixel
).
This demonstrates aliasing occurring when "a high frequency signal is masquarading as a low frequency signal."
Pixels Per Cycle: | 400 |
---|---|
Cycles Per Pixel: | 400 |
The canvas below is 400 pixels wide.
Pixels Per Cycle
appear to be?
Pixels Per Cycle
appear to be?
(Undoubtedly, it appears to be a very, very low frequency).
uniform mediump float u_pixels_per_cycle;
void main() {
// note, we normalize sin to vary from 0 to 1, and use that as intensity variation
gl_FragColor = vec4(1.0, 1.0, 1.0,1.0) * (0.5*sin( (gl_FragCoord.x)/u_pixels_per_cycle*2.0*pi)+0.5);
gl_FragColor[3]=1.0;
}