threejs-shaders

Implement custom GLSL shaders in Three.js with ShaderMaterial and RawShaderMaterial.

Updated Jan 31, 2026
One-click install
npx skills add https://github.com/Clinscott/CStar --skill threejs-shaders-clinscott
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: threejs-shaders
Source: https://github.com/Clinscott/CStar/tree/main/skills_db/threejs-skills/skills/threejs-shaders
Command: npx skills add https://github.com/Clinscott/CStar --skill threejs-shaders-clinscott

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Implementing custom GLSL shaders in Three.js can be complex and error-prone without a structured guide to uniforms, varyings, and shader patterns.

Core Features & Use Cases

  • ShaderMaterial and RawShaderMaterial usage for custom vertex/fragment shaders.
  • Uniforms, varyings, and common shader patterns (texture sampling, vertex displacement, Fresnel effects, and instanced shaders).
  • Extending built-in materials via onBeforeCompile and robust shader debugging for production-ready visuals.

Quick Start

Create a ShaderMaterial in Three.js with a basic vertex and fragment shader and gradually update its uniforms in your animation loop.

Frequently Asked Questions about threejs-shaders

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

FAQPage Schema
How do I implement custom GLSL shaders in Three.js?

Implement custom GLSL shaders in Three.js by creating a ShaderMaterial with vertex and fragment shader code, defining uniforms and varyings, then updating those uniforms each frame in your animation loop to drive real-time 3D visual effects.

What is the difference between ShaderMaterial and RawShaderMaterial in Three.js?

ShaderMaterial automatically injects Three.js built-in uniforms, attributes, and prefixes, whereas RawShaderMaterial provides a blank canvas requiring you to manually declare all GLSL variables for full control over shader compilation.

How do I extend built-in Three.js materials with custom shader code?

Extend built-in Three.js materials by using the onBeforeCompile function to inject custom GLSL snippets into the shader pipeline, enabling vertex displacement or Fresnel effects while retaining the base material's built-in lighting and uniforms.

Why is my Three.js ShaderMaterial not rendering correctly?

Three.js ShaderMaterial rendering failures often stem from undefined uniforms, mismatched varying declarations between vertex and fragment shaders, or missing GLSL precision qualifiers, requiring systematic shader debugging and compatibility checks.

What are common GLSL shader patterns for Three.js visual effects?

Common GLSL shader patterns in Three.js include vertex displacement for geometry deformation, texture sampling for material mapping, and Fresnel effects for edge lighting, driven by uniforms and varyings for dynamic visual results.