Skip to content
dev-r3f-r3f-materials logo

R3F Materials

dev-r3f-r3f-materials

Material selection, shaders, and visual effects for R3F

SKILL.md

Full skill instructions

R3F Materials

"Materials define the soul of your 3D objects – choose wisely."

When to Use This Skill

Use when:

  • Choosing material type for objects
  • Creating custom shaders
  • Implementing visual effects
  • Optimizing material performance

Quick Start

// Standard PBR material (recommended default)
<meshStandardMaterial
  color="royalblue"
  roughness={0.5}
  metalness={0.5}
/>

// Basic material (unlit, best performance)
<meshBasicMaterial color="red" />

// Physical material (advanced PBR)
<meshPhysicalMaterial
  clearcoat={1}
  clearcoatRoughness={0.1}
  transmission={0.9}
  thickness={0.5}
/>

Decision Framework

NeedMaterialPerformance
Unlit colormeshBasicMaterial⚡ Fastest
Simple shadingmeshLambertMaterial⚡⚡ Fast
Stylized lookmeshToonMaterial⚡⚡ Fast
Realistic PBRmeshStandardMaterial⚡⚡⚡ Medium
Glass/​watermeshPhysicalMaterial⚡⚡⚡⚡ Slow
Custom effectsshaderMaterialVaries
Matcap lightingmeshMatcapMaterial⚡⚡ Fast

Progressive Guide

Level 1: Standard Materials

// Most common choice - good balance of quality and performance
<meshStandardMaterial
  color="#ff6600"
  roughness={0.7} // 0 = smooth, 1 = rough
  metalness={0.3} // 0 = dielectric, 1 = metal
  envMapIntensity={1}
/>

Level 2: Textured Materials

import { useTexture } from '@react-three/​drei';

function TexturedMesh() {
  const [colorMap, normalMap, roughnessMap] = useTexture([
    '/​textures/​color.jpg',
    '/​textures/​normal.jpg',
    '/​textures/​roughness.jpg',
  ]);

  return (
    <mesh>
      <boxGeometry />
      <meshStandardMaterial map={colorMap} normalMap={normalMap} roughnessMap={roughnessMap} />
    </​mesh>
  );
}

Level 3: Matcap Materials (Fast & Stylized)

import { useMatcapTexture } from '@react-three/​drei';

function MatcapMesh() {
  const [matcap] = useMatcapTexture('3B3C3F_DAD9D5_929290_ABACA8');

  return (
    <mesh>
      <sphereGeometry />
      <meshMatcapMaterial matcap={matcap} />
    </​mesh>
  );
}

Level 4: Custom Shaders

import { shaderMaterial } from '@react-three/​drei';
import { extend, useFrame } from '@react-three/​fiber';

const WaveShaderMaterial = shaderMaterial(
  { uTime: 0, uColor: new THREE.Color('hotpink') },
  // Vertex shader
  `
    uniform float uTime;
    varying vec2 vUv;

    void main() {
      vUv = uv;
      vec3 pos = position;
      pos.z += sin(pos.x * 4.0 + uTime) * 0.1;
      gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
    }
  `,
  // Fragment shader
  `
    uniform vec3 uColor;
    varying vec2 vUv;

    void main() {
      gl_FragColor = vec4(uColor, 1.0);
    }
  `
);

extend({ WaveShaderMaterial });

function WavyPlane() {
  const materialRef = useRef();

  useFrame((state) => {
    if (materialRef.current) {
      materialRef.current.uTime = state.clock.elapsedTime;
    }
  });

  return (
    <mesh>
      <planeGeometry args={[4, 4, 32, 32]} />
      <waveShaderMaterial ref={materialRef} />
    </​mesh>
  );
}

Level 5: Transparent & Glass

// Glass/​water with transmission
<meshPhysicalMaterial
  transmission={0.95}      // 0-1, how much light passes through
  thickness={0.5}          // Simulated thickness
  roughness={0.05}
  ior={1.5}               // Index of refraction
  clearcoat={1}
  clearcoatRoughness={0.1}
/>

// Simple transparency
<meshStandardMaterial
  transparent
  opacity={0.5}
  side={THREE.DoubleSide}
/>

Material Comparison

PropertyBasicLambertStandardPhysical
LightingNoDiffusePBRAdvanced PBR
RoughnessNoNoYesYes
MetalnessNoNoYesYes
ClearcoatNoNoNoYes
TransmissionNoNoNoYes
GPU CostLowLowMediumHigh

Anti-Patterns

DON'T:

  • Use meshPhysicalMaterial everywhere (performance killer)
  • Create new materials every render
  • Forget side={THREE.DoubleSide} for visible interiors
  • Use transmission without proper scene setup
  • Skip texture optimization (uncompressed textures)

DO:

  • Use simplest material that achieves the look
  • Reuse materials across similar objects
  • Use meshBasicMaterial for distant/​small objects
  • Compress textures (WebP, basis universal)
  • Use material instances with drei

Performance Tips

// Share materials across instances
const sharedMaterial = useMemo(
  () => new THREE.MeshStandardMaterial({ color: 'red' }),
  []
);

// Use for many objects
<mesh material={sharedMaterial}>...</​mesh>
<mesh material={sharedMaterial}>...</​mesh>

Checklist

Before finalizing materials:

  • Appropriate material type for use case
  • Textures are optimized (compressed, power-of-2)
  • Materials shared where possible
  • Transparent materials have transparent: true
  • Double-sided materials explicitly set
  • Shader uniforms use refs for animation

Reference

  • Three.js Materials — Official docs
  • developer/​r3f/​r3f-fundamentals.md — R3F basics
  • developer/​performance/​performance-basics.md — Optimization

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View