shader:start

This is an old revision of the document!


Shaders

A memo in GLSL programming.

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;

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 stands for Interactive Shader Format and is a file format used to describe GLSL shaders for real-time image filtering and generation.

* ISF Main Site

* Graph Toy : Display math functions

* Color Palettes : Interactive Color Palettes

* Desmos : Great math tools

  • shader/start.1747822851.txt.gz
  • Last modified: 2025/06/02 21:18
  • (external edit)