ShaderToy Demos

Posted: 27 Jul 2021. Last modified on 04-Jun-22.

This article will take about 1 minute to read.


I recently discovered GLSL (OpenGL’s Shader Language), and had some fun with trying it out on ShaderToy. Shaders are small compiled programs that run on the GPU. There are multiple types:

The ones that I wrote on ShaderToy are fragment shaders, short for pixel fragment. The concept behind them is simple - they just emit a pixel value as a 4d vector. The shader gets called for every pixel in the image, up to 60 times a second.


Demos


Snippets

Makes the viewport fit the size of the canvas we are drawing into

vec2 normalizeResolution(vec2 fragCoord) {
    return fragCoord.xy / iResolution.xy;
}

Creates a rippling effect

uv += cos(cLength * 15.0 - iTime * 4.0);

References