Run a custom shader (Water)
site/media/lessons/scenes-batch.lesson.ts (4 steps) A scene material of type: 'custom' resolves a named material-def from the registry. The
water-shader scene uses the shipped Water def — a ShaderMaterial that animates itself.
-
Open the water-shader scene. Load
examples/scenes/water-shader.vscn.json.
The water-shader scene. -
Enter play mode — the custom Water material runs. The registry resolves the
waterdef andbuild()returns aShaderMaterial.
The custom Water material. -
The shader animates waves via its
uTimeuniform. The def’supdate(dt, …)advancesuTimeeach frame; the vertex shader displaces the surface with summed sine waves.
Self-animating shader (uTime). -
Stop play mode. Press Stop (or
Escape).
Recap
New functionality
- Ran a scene using a custom material
- Saw a self-animating GLSL ShaderMaterial
New concepts & skills
- type: 'custom' resolves a named MaterialDef from the registry
- build() returns a THREE.Material; update() ticks self-animating uniforms
- Inline GLSL in .vscn is not supported — use a registered def
Next lesson → Manual: Custom shaders
On Your Own!
Extend what you built:
- Tweak the Water def's wave height/speed uniforms
- Register a second custom def (e.g. a pulsing emissive) and use it in a scene
- Read the custom-shaders manual page for the full MaterialDef contract