This is an old revision of the document!
Shaders
A memo in GLSL programming.
Coding Shaders
Normalized input Coordinates
Generally the vec2 uv
is used to describe a normalized input coordinates by dividing the coordinate by the current resolution :
Different compilers use different syntax to describe the resolution.
vec2 uv = fragCoord.xy / iResolution.xy;
Origin
The origin (0.0 ; 0.0) of this normalized vector is the bottom left.
To move the origin to the center of the screen, remove 0.5 to both components :
uv -= 0.5;
Aspect Ratio
To correct the aspect ratio on non-square displays, we multiply one component (generally x
) by the Resolution's aspect ratio.
uv.x *= iResolution.x / iResolution.y;
Circle
To draw a circle, define a center point where the circle should be drawn and use a length function to calculate the length of the coordinates to this center.
If it is larger than a value draw a color, if not draw another color.
ISF
ISF stands for Interactive Shader Format and is a file format used to describe GLSL shaders for real-time image filtering and generation.
Ressources
Online Editors
Tools
* Graph Toy : Display math functions
* Color Palettes : Interactive Color Palettes
* Desmos : Great math tools