learn GLSL from zero
ToolsCreate with shadersShader MakerFree online shader builderToolkitShader works ready for your siteSketcher LabPaint your landing’s hero with shaders3D StudioThe Three.js editor in your browser
GamesPlay with shadersOnomatoShaderType a word, blow it upThe WatcherAn eye that follows youAetherLiquid glass with an eye insideBloomcoreA word grows a garden of lightPyrokineThrow fire at the wallVoltaicThe pyramid throws lightningSurfSurf a shader ocean

Lesson 5 of 10 · Noise in GLSL

Motion

Static becomes live. One line.

Static FBM is a photo. Add T to the coordinates and it starts moving. The speed changes everything.

A cascade of bits no one stopped.

fb(p + T * vel)Time shifts the coordinates. The noise is calculated at a position that changes every frame.
TryChange 0.5 (base speed) to 2., frenetic. To 0.1, everything falls slow. Change 1.5 (how much each column varies) to 0. and all columns fall at the same rate.

The code

void main(){
  vec2 p = (2.*gl_FragCoord.xy - R) / min(R.x, R.y);
  float col_id = floor(p.x * 10.0);
  float speed = 0.5 + h2(vec2(col_id, 0.0)) * 1.5;
  float scrolled = p.y + T * speed;
  vec2 grid = vec2(col_id, floor(scrolled * 8.0));
  float id = h2(grid);
  float on = step(0.4, id);
  float bright = step(0.85, id);
  float trail = exp(-fract(scrolled * 8.0) * 3.0);
  vec3 col = vec3(0.0, on * 0.5 * trail, on * 0.4 * trail);
  col += vec3(0.0, 0.9, 0.7) * bright * trail;
  col += vec3(0.01, 0.02, 0.02);
  gl_FragColor = vec4(col, 1.);
}
close