threejs-shaders covers writing custom shaders for three.js. Its quick start builds a ShaderMaterial with a time uniform, a color uniform, a varying for UV coordinates and a fragment shader that animates a wave, ending with the tone mapping and color space includes.
It explains how ShaderMaterial and RawShaderMaterial differ, how three.js compiles shaders as GLSL ES 3.00, and how to reproduce the same effects with node materials and TSL on WebGPU.
What You Get
- A runnable ShaderMaterial with an animated time uniform
- An explanation of ShaderMaterial versus RawShaderMaterial and the GLSL version three.js prepends
- Coverage of shader chunks, extending built-in materials and instanced attributes
- Notes on migrating older GLSL, including names that no longer compile
- TSL and node material versions of the same effects for WebGPU
Common Use Cases
- Writing an animated surface effect
- Moving vertices in a vertex shader
- Extending a standard material with a few custom lines
- Passing per-instance data to a shader
- Porting a GLSL shader to TSL
What Makes It Unique
It covers both shader paths, GLSL for WebGL and TSL for WebGPU, which matches the current three.js guidance for custom materials. It also lists the specific cases where older GLSL fails to compile, such as an extension line or a variable named texture. It is pinned to r186.
Under The Hood
The skill is a single SKILL.md of explanation and JavaScript examples with embedded GLSL, with no scripts, and it tells the agent to run no commands. The agent reads it and writes three.js and shader code into your project. It fetches nothing and writes no files itself.