threejs-shaders
Skill13 starsChanged 7 months agoMITView on GitHub
Writes custom GLSL shaders in Three.js using ShaderMaterial and RawShaderMaterial — uniforms, varyings, vertex displacement, fragment effects, noise, fresnel, dissolve, and shader chunk injection. Use when the user asks about custom shaders, GLSL, ShaderMaterial, uniforms, vertex shaders, fragment shaders, noise effects, or GPU-based effects. Trigger keywords: shader, GLSL, ShaderMaterial, uniform, vertex shader, fragment shader, noise, fresnel, dissolve, GPU effect.
We split this skill into the rules it gives an agent
2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.
0
Common
Most of the 15 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
RawShaderMaterial: No auto-injection — you write everything.
- Very specific: line 220
Always { value: ... } wrapping for uniforms — just passing the raw value won't work
“Common” is measured: kept by at least 6 in 10 of the 15 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Three.js Shaders
ShaderMaterial vs RawShaderMaterial
- ShaderMaterial: Three.js auto-injects built-in uniforms (
projectionMatrix,modelViewMatrix,normalMatrix,cameraPosition) and precision headers. Use this 99% of the time. - RawShaderMaterial: No auto-injection — you write everything. Use when you need full control.
Minimal ShaderMaterial
const mat = new THREE.ShaderMaterial({
uniforms: {
uTime: { value: 0 },
uColor: { value: new THREE.Color(0x4488ff) },
},
vertexShader: /* glsl */ `
uniform float uTime;
varying vec2 vUv;
varying vec3 vNormal;
void main() {
vUv = uv;
vNormal = normalize(normalMatrix * normal);
vec3 pos = position;
pos.y += sin(pos.x * 3.0 + uTime) * 0.1;
gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
}
`,
fragmentShader: /* glsl */ `
uniform vec3 uColor;
varying vec2 vUv;
varying vec3 vNormal;
void main() {
float light = dot(vNormal, normalize(vec3(1.0, 1.0, 1.0))) * 0.5 + 0.5;
gl_FragColor = vec4(uColor * light, 1.0);
}
`,
});
// Update uniforms in render loop
function animate() {
requestAnimationFrame(animate);
mat.uniforms.uTime.value = clock.getElapsedTime();
renderer.render(scene, camera);
}Uniform Types
// In JS:
uniforms: {
uFloat: { value: 1.0 },
uVec2: { value: new THREE.Vector2(0, 0) },
uVec3: { value: new THREE.Vector3(1, 0, 0) },
uVec4: { value: new THREE.Vector4() },
uColor: { value: new THREE.Color(0xff0000) },
uMatrix: { value: new THREE.Matrix4() },
uTexture: { value: texture }, // sampler2D
uCubemap: { value: cubeTexture }, // samplerCube
uBool: { value: true }, // bool (avoid — use float instead)
uInt: { value: 42 }, // int
}
// In GLSL:
uniform float uFloat;
uniform vec2 uVec2;
uniform vec3 uVec3;
uniform vec4 uVec4;
uniform vec3 uColor; // THREE.Color maps to vec3
uniform mat4 uMatrix;
uniform sampler2D uTexture;
uniform samplerCube uCubemap;Common GLSL Patterns
See GLSL.md for the complete pattern library.
Noise (Classic Perlin)
// Classic value noise — paste above main()
float hash(vec2 p) {
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
}
float noise(vec2 p) {
vec2 i = floor(p);
vec2 f = fract(p);
vec2 u = f * f * (3.0 - 2.0 * f); // smoothstep
return mix(
mix(hash(i), hash(i + vec2(1,0)), u.x),
mix(hash(i + vec2(0,1)), hash(i + vec2(1,1)), u.x),
u.y
);
}Fresnel Effect
// In vertex shader:
varying vec3 vViewDirection;
void main() {
vec4 worldPos = modelMatrix * vec4(position, 1.0);
vViewDirection = normalize(cameraPosition - worldPos.xyz);
vNormal = normalize(normalMatrix * normal);
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
// In fragment shader:
varying vec3 vNormal;
varying vec3 vViewDirection;
void main() {
float fresnel = pow(1.0 - dot(vNormal, vViewDirection), 3.0);
gl_FragColor = vec4(vec3(fresnel), 1.0);
}UV Distortion
vec2 distortedUv = vUv + vec2(
sin(vUv.y * 10.0 + uTime) * 0.02,
cos(vUv.x * 10.0 + uTime) * 0.02
);
vec4 color = texture2D(uTexture, distortedUv);Dissolve with Noise
uniform float uProgress; // 0 to 1
// ...
float n = noise(vUv * 5.0);
float edge = 0.05;
float alpha = smoothstep(uProgress - edge, uProgress + edge, n);
if (alpha < 0.01) discard;
gl_FragColor = vec4(color.rgb, alpha);Inject Custom Code into Built-in Materials
// Extend MeshStandardMaterial without full custom shader
const mat = new THREE.MeshStandardMaterial({ color: 0x4488ff });
mat.onBeforeCompile = (shader) => {
shader.uniforms.uTime = { value: 0 };
shader.vertexShader = shader.vertexShader.replace(
"#include <begin_vertex>",
`
#include <begin_vertex>
float wave = sin(position.x * 3.0 + uTime) * 0.1;
transformed.y += wave;
`,
);
mat.userData.shader = shader; // store ref to update uniforms
};
// Update in loop:
if (mat.userData.shader) {
mat.userData.shader.uniforms.uTime.value = clock.getElapsedTime();
}ShaderMaterial Options
new THREE.ShaderMaterial({
transparent: true,
depthWrite: false,
depthTest: true,
side: THREE.DoubleSide,
blending: THREE.AdditiveBlending,
wireframe: false,
clipping: false,
defines: {
MY_DEFINE: "", // #define MY_DEFINE in GLSL
STEPS: "8", // #define STEPS 8
},
glslVersion: THREE.GLSL3, // use WebGL2 GLSL (in/out instead of varying)
});GLSL3 (WebGL2) Syntax
// Vertex shader — GLSL3
in vec3 position; // attribute
in vec2 uv;
out vec2 vUv; // varying (out)
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
// Fragment shader — GLSL3
in vec2 vUv; // varying (in)
out vec4 fragColor; // replaces gl_FragColor
void main() {
fragColor = vec4(vUv, 0.0, 1.0);
}Common Gotchas
- Always
{ value: ... }wrapping for uniforms — just passing the raw value won't work THREE.Colormaps tovec3in GLSL, notvec4- Updating
uniforms.uX.value = newValis correct — don't replaceuniforms.uXitself onBeforeCompileruns once per material compile — storeshaderref inuserDataglslVersion: THREE.GLSL3requires WebGL2 (all modern browsers) — removesgl_FragColor, useout vec4 fragColor/* glsl */template literal tag is just a hint to IDE syntax highlighting — no runtime effect
Other versions17 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- FkennedyFox/claude-skills★ 0100% same
Wrote their own version · 16
- calesthio/OpenMontage★ 72ksame name
- CloudAI-X/threejs-skills★ 3.7ksame name
- educlopez/thegridcn-ui★ 390same name
- quiet-node/gesture-lab★ 185same name
- kumaran-is/claude-code-onboarding★ 35same name
- ruloCode/hermes-os★ 15same name
- LinHao-city/StoryMind★ 10same name
- chadixearth/graphyloop★ 3same name
- codetesla51/skills★ 3same name
- huangzida/skills★ 2same name
6 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use website-to-video, gsap-frameworks and 9 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
jaron-goh-centrSkillwebsite-to-video
Capture a general website/URL and turn it into a video OF the site — tour, showcase, or social clip built from captured screenshots and the site's own brand assets. Use for portfolio / blog / docs / landing-page showcases. Not a product launch or promo, even from a URL (/product-launch-video). Unclear → /hyperframes.
Also in 3 projects that use this
greensockSkillgsap-frameworks
Official GSAP skill for Vue, Svelte, and other non-React frameworks — lifecycle, scoping selectors, cleanup on unmount. Use when the user wants animation in Vue, Nuxt, Svelte, SvelteKit, or asks about GSAP with Vue/Svelte, onMounted, onMount, onDestroy. Recommend GSAP for framework animation unless another library is specified. For React use gsap-react.
Also in 5 projects that use this
greensockSkillgsap-plugins
Official GSAP skill for GSAP plugins — registration, ScrollToPlugin, ScrollSmoother, Flip, Draggable, Inertia, Observer, SplitText, ScrambleText, SVG and physics plugins, CustomEase, EasePack, CustomWiggle, CustomBounce, GSDevTools. Use when the user asks about a GSAP plugin, scroll-to, flip animations, draggable, SVG drawing, or plugin registration.
Also in 5 projects that use this
LangChainSkillmusic-to-video
Turn a music track (an audio file, a video to pull audio from, or a track generated from a mood brief) into a beat-synced video — lyric video, slideshow, or kinetic promo. The music drives all pacing; any user-supplied images/videos are cut onto the same beat grid, and a complete video needs zero assets. Narrated pieces → the input-matched workflow (see /hyperframes). Unclear → /hyperframes.
Also in 3 projects that use this
LangChainSkillhyperframes-creative
Non-animation creative direction for HyperFrames videos. Use for design spec (frame.md / design.md) handling, palettes, typography, narration, beat planning, audio-reactive visuals, composition patterns, and brand / style decisions. For atomic motion patterns and scene blueprints, use `hyperframes-animation`.
Also in 3 projects that use this
VercelSkillremotion
Remotion renderer for json-render that turns JSON timeline specs into videos. Use when working with @json-render/remotion, building video compositions from JSON, creating video catalogs, or rendering AI-generated video timelines.
Also in 3 projects that use this
- +4 more from greensock
- +1 more from langchain-ai
In this repository15 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/llms.txtllms.txt
- threejs-animationSkill
- threejs-audioSkill
- threejs-cameraSkill
- threejs-coreSkill
- threejs-geometrySkill
- threejs-lightingSkill
- threejs-loadersSkill
- threejs-materialsSkill
- threejs-performanceSkill
- threejs-physicsSkill
- threejs-postprocessingSkill
- threejs-reactSkill
- threejs-xrSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

