threejs-shaders

Create custom Three.js shader code for vertex and fragment materials.

Updated Apr 3, 2026
One-click install
npx skills add https://github.com/norrbacka/threejs_codex_base --skill threejs-shaders-norrbacka
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: threejs-shaders
Source: https://github.com/norrbacka/threejs_codex_base/tree/main/.codex/skills/threejs-shaders
Command: npx skills add https://github.com/norrbacka/threejs_codex_base --skill threejs-shaders-norrbacka

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill removes the trial-and-error from writing custom Three.js shaders by giving you a practical guide for building, updating, and debugging vertex and fragment materials.

Core Features & Use Cases

  • Custom Shader Authoring: Create ShaderMaterial and RawShaderMaterial setups with uniforms, varyings, texture sampling, and GLSL patterns.
  • Material Patching: Extend built-in Three.js materials with onBeforeCompile for targeted visual changes without rewriting the whole shader.
  • Advanced Visual Effects: Implement effects such as noise, Fresnel, rim lighting, dissolve transitions, vertex displacement, and instanced rendering.
  • Use Case: Ask for a shader that animates a surface, reads a texture, and blends an edge glow effect into an existing Three.js material.

Quick Start

Use the threejs-shaders skill to generate or adapt a Three.js shader for my scene, including the material setup, uniforms, and any needed GLSL changes.

Frequently Asked Questions about threejs-shaders

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write custom Three.js shaders for vertex and fragment materials?

Writing custom Three.js shaders involves creating ShaderMaterial or RawShaderMaterial with GLSL uniforms, varyings, and texture sampling. You define vertex and fragment shaders to process geometry and pixels, using onBeforeCompile to patch built-in materials for targeted visual changes.

What is onBeforeCompile in Three.js and when should I use it?

onBeforeCompile in Three.js is a method to patch built-in materials by injecting custom GLSL code. You should use it to make targeted visual changes like edge glow or dissolve transitions without rewriting the entire shader, preserving the existing rendering workflow.

How do I create advanced visual effects like noise or Fresnel in GLSL?

Creating advanced visual effects like noise or Fresnel in GLSL requires implementing mathematical functions within fragment shaders. You calculate surface angles and blend textures using uniforms and varyings to achieve shader-driven visuals like rim lighting or vertex displacement.

Does this approach support instanced geometry and GLSL3 in Three.js?

Yes, custom Three.js shaders support instanced geometry rendering and GLSL3. You can use RawShaderMaterial with GLSL3 syntax to handle instanced rendering workflows, satisfying constraints for reliable rendering across multiple objects.

How do I debug custom shader code in a Three.js scene?

Debugging custom shader code in a Three.js scene involves checking GLSL compilation errors and validating uniform values. You can isolate issues by testing built-in chunks and verifying that varyings correctly pass data between vertex and fragment shaders.

What is the best way to add a dissolve transition to an existing Three.js material?

The best way to add a dissolve transition to an existing Three.js material is using onBeforeCompile to patch the shader. This lets you inject noise functions and texture sampling directly into the built-in material for the transition effect.