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 10 of 10 · Shader patterns

Your pattern

Chladni, star, spiral, rings. All visible.

This lesson does not teach anything new. It brings together everything you learned in Patterns: stripes, fract, polar, spiral, mirror, radials, Chladni.

Your variables. Your frequencies. Your signature.

Look at the code. You already know every line:

This is your pattern. Make it yours.

TryChange 5. for more or fewer radials. Change 8. for more or fewer spiral twists. Change the colors. This pattern is yours now.
Freebie

AUTOPILOT

Replace the line col += vec3(.12,.08,.2) * chladni * (1.-star); with this:
col += iri(chladni * 0.4 + T * 0.05) * chladni * (1.-star);

The background breathes.

The code

void main(){
  vec2 p = (2.*gl_FragCoord.xy - R) / min(R.x, R.y);
  float ang = atan(p.y, p.x);
  float d = length(p);
  float z = sin(5.*3.14*p.x)*sin(3.*3.14*p.y)+sin(3.*3.14*p.x)*sin(5.*3.14*p.y);
  float chladni = pow(abs(z), 0.8);
  float r = 0.6 + 0.2 * sin(ang*5.+T*0.3);
  float star = smoothstep(0.02, -0.02, d-r);
  float spiral = step(0.5, sin(ang*3.+d*8.-T*0.5)*.5+.5);
  float rings = smoothstep(0.03,0.0, abs(fract(d*4.)-.5)-.3);
  vec3 col = vec3(0.02, 0.015, 0.04);
  col += vec3(.12,.08,.2) * chladni * (1.-star);
  col += vec3(.95,.3,.15) * star * spiral;
  col += vec3(0.,.85,.75) * star * (1.-spiral);
  col += vec3(.95,.8,.15) * rings * .3;
  col += vec3(.5,.15,.08) * exp(-abs(d-r)*4.) * .5;
  col += vec3(.8,.6,.95) * exp(-d*3.) * .4;
  gl_FragColor = vec4(col, 1.);
}
close