threejs-materials

Configure Three.js materials for shading, textures, and runtime performance.

2|Updated Jan 30, 2026
One-click install
npx skills add https://github.com/ElementTech/create-threejs-game --skill threejs-materials-elementtech
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: threejs-materials
Source: https://github.com/ElementTech/create-threejs-game/tree/main/template/.claude/skills/threejs-materials
Command: npx skills add https://github.com/ElementTech/create-threejs-game --skill threejs-materials-elementtech

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides clear, practical guidance for selecting, configuring, and optimizing materials in Three.js so developers can achieve the intended visual look while minimizing runtime cost and integration errors.

Core Features & Use Cases

  • Material reference: Covers MeshBasic, MeshLambert, MeshPhong, MeshStandard, MeshPhysical, MeshToon, MeshNormal, MeshDepth, Points, Line, ShaderMaterial, and RawShaderMaterial.
  • Texture and map guidance: Explains albedo, normal, roughness, metalness, AO, displacement, emissive, clearcoat, transmission, sheen, iridescence, anisotropy, and env maps, plus uv2 requirements.
  • Shader and advanced effects: Shows when to use ShaderMaterial/RawShaderMaterial and lists common built-in uniforms and attributes.
  • Performance and lifecycle: Reuse and pooling strategies, when to dispose materials, and tips to reduce draw calls and sorting overhead.
  • Use Case: Style game assets with PBR for realistic visuals, tune car paint or glass with PhysicalMaterial, or implement stylized toon shading for a cartoon look.

Quick Start

Use the threejs-materials skill to generate or configure appropriate Three.js material settings for a mesh based on its textures and desired visual style.

Frequently Asked Questions about threejs-materials

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

FAQPage Schema
How do I configure Three.js MeshStandardMaterial for PBR textures?

Three.js MeshStandardMaterial supports PBR by applying albedo, normal, roughness, metalness, and AO texture maps to their respective material properties. You must also configure uv2 coordinates on the mesh for ambient occlusion mapping to achieve physically accurate shading.

What is the difference between MeshStandardMaterial and MeshPhysicalMaterial in Three.js?

MeshPhysicalMaterial extends MeshStandardMaterial to support advanced physical rendering properties like clearcoat, transmission, sheen, iridescence, and anisotropy. Choose MeshPhysicalMaterial for specialized surfaces like car paint or glass, and MeshStandardMaterial for standard PBR to reduce runtime cost.

How do I optimize Three.js material performance and reduce draw calls?

Optimize Three.js materials by reusing material instances across meshes and implementing material pooling strategies. Properly dispose of unused materials to prevent memory leaks, and choose simpler material types like MeshBasicMaterial when advanced physical shading is not required to reduce sorting overhead.

When should I use ShaderMaterial instead of MeshPhongMaterial in Three.js?

Use ShaderMaterial or RawShaderMaterial when you need custom GLSL shading effects beyond built-in physical or toon models. MeshPhongMaterial is suitable for simpler specular highlights, while ShaderMaterial allows direct access to built-in uniforms and attributes for unique visual styles and advanced rendering tasks.

How do I set up environment maps for realistic reflections in Three.js?

Set up environment reflections in Three.js by assigning an HDR environment map to the material's envMap property. This enables physical materials like MeshStandardMaterial and MeshPhysicalMaterial to calculate accurate surface reflections, enhancing the physical realism of metals and glossy surfaces.

Can I create toon shading effects with Three.js materials?

Yes, Three.js provides MeshToonMaterial specifically for creating stylized cartoon shading effects. It simplifies continuous gradients into distinct bands of color, making it ideal for interactive visualizations and web games that require a stylized non-photorealistic visual look.