PluginBench
Skill
Review
Audit score 70

r3f-textures

enzed/r3f-skills

Configure textures in React Three Fiber: color spaces, UV channels, sampling, video, and render targets.

What is r3f-textures?

Manage texture appearance and memory in React Three Fiber by correctly applying color spaces, handling UV channels, configuring sampling, and working with specialized textures like video and render targets. Use this skill when debugging texture appearance issues, optimizing memory usage, or setting up custom texture workflows beyond standard model loading.

  • Apply correct color-space annotations (sRGB for colors, NoColorSpace for data) to prevent visual artifacts
  • Configure UV channels, wrapping, filtering, and texture transforms for proper sampling and atlas animations
  • Load and manage color maps, video textures, and canvas/data textures with proper lifecycle handling
  • Clone and cache textures efficiently to avoid unintended side effects across multiple consumers
  • Set up render targets and specialized textures while avoiding common pitfalls like simultaneous read/write

How to install r3f-textures

npx skills add https://github.com/enzed/r3f-skills --skill r3f-textures
Prerequisites
  • React Three Fiber 9+ and Three.js r185 or compatible versions
  • @react-three/drei for useTexture and useVideoTexture utilities
  • Understanding of WebGL texture concepts and color management basics
Claude Code
Cursor
Windsurf
Cline

How to use r3f-textures

  1. 1.Identify whether your texture contains color data (PNG/JPEG base color) or scalar/vector data (roughness, normal maps, masks)
  2. 2.Apply the appropriate color-space annotation: SRGBColorSpace for colors, NoColorSpace for data, or preserve loader-provided metadata for HDR/EXR
  3. 3.Load textures using useTexture from Drei, optionally configuring color space in the callback
  4. 4.For per-instance variations, clone the cached texture object and update owned properties; avoid disposing the shared cache source
  5. 5.Configure UV channels, wrapping, and filtering based on your geometry attributes and visual requirements; use texture.needsUpdate only when necessary for configuration changes

Use cases

Good for
  • Fixing texture appearance issues caused by incorrect color-space configuration in custom shaders or manually created textures
  • Optimizing GPU memory and download size by configuring appropriate texture dimensions, compression formats, and filtering
  • Implementing video textures with proper autoplay, CORS, and lifecycle management
  • Setting up per-instance texture variations by cloning cached textures and managing ownership separately
  • Configuring atlas animations and texture transforms without creating React state per frame
Who it's for
  • React Three Fiber developers working with custom textures or shaders
  • Graphics engineers optimizing texture memory and visual quality
  • Developers implementing specialized textures like video or render targets
  • Teams managing texture caches and preventing resource leaks in complex scenes

r3f-textures FAQ

When should I use SRGBColorSpace versus NoColorSpace?

Use SRGBColorSpace for color content like base color and emissive maps. Use NoColorSpace for scalar/vector data like roughness, metalness, normal maps, AO, and alpha masks. NoColorSpace is not the same as LinearSRGBColorSpace; data has no color space.

How do I avoid texture cache conflicts when multiple components use the same texture?

Clone the Texture object before making per-instance changes like repeat, offset, or wrapping. Reuse the underlying image data and dispose only the clone you own, not the cached source.

Do I need power-of-two texture dimensions?

No. Power-of-two is not a universal WebGL2 requirement. Size textures based on screen coverage, memory constraints, compression-format support, and quality instead.

What's the difference between texture.needsUpdate for offset/repeat versus other changes?

Offset and repeat changes use the texture matrix and do not require re-uploading image data, so needsUpdate is not necessary. Configuration changes like color space or wrapping may require needsUpdate.

How should I handle video textures?

Use useVideoTexture when its lifecycle fits your use case. Check autoplay/muting, CORS, user gestures, and source cleanup; changing video resolution requires a new texture. Do not assume autoplay succeeds on all browsers.

Full instructions (SKILL.md)

Source of truth, from enzed/r3f-skills.


name: r3f-textures description: Configure textures in React Three Fiber, including color spaces, UV channels, sampling, video, and render targets. Use for texture appearance or memory issues; use loader guidance for model-loading workflows.

React Three Fiber textures

Inspect installed Three.js, Fiber, Drei, and renderer versions first. Examples target Fiber 9 / React 19 and Three.js r185 with WebGL. Preserve correctly configured assets rather than resetting every texture.

Color versus data

Texture contentColor-space annotation
PNG/JPEG base color or emissive colorSRGBColorSpace
Roughness, metalness, normal, AO, alpha/masksNoColorSpace
Linear HDR/EXR lighting dataPreserve loader-provided linear metadata

NoColorSpace is not another name for LinearSRGBColorSpace: scalar/vector data has no color space. Do not blanket-convert every map to sRGB.

Load a color map

Mount under Suspense inside Canvas. The file path is an application asset, not a file provided by this skill.

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

export default function Example() {
  const map = useTexture('/textures/checker.png', (texture) => {
    // This URL is consistently used as a color texture by all consumers.
    texture.colorSpace = SRGBColorSpace
    texture.needsUpdate = true
  })
  return (
    <mesh>
      <planeGeometry args={[3, 3]} />
      <meshStandardMaterial map={map} roughness={1} />
    </mesh>
  )
}

Fiber handles common built-in color map props, and glTF loaders set texture metadata. Explicit annotation is especially important for custom shader uniforms or manually created textures.

Cache and ownership

  • useTexture/useLoader cache by loader and URL inputs. The same source can return the same Texture object. Repeat, offset, wrapping, filters, and colorSpace changes can affect every consumer.
  • Clone the Texture object before per-instance configuration. Reuse the underlying image where possible; separately dispose only the clone you own. Do not dispose the cached source from an individual consumer.
  • Do not clear a loader cache during render. Cache eviction and GPU disposal are separate operations and require knowing that no active consumer still needs the resource.
  • Avoid replacing the uniform/texture object every frame; update offsets or owned values directly. On a demand loop, invalidate after imperative changes.

UVs and sampling

  • texture.channel = 0 selects uv, 1 selects uv1, then uv2 and uv3. Choose the actual geometry attribute; AO/light maps no longer universally require copying uv into uv2.
  • Repeat outside [0, 1] requires RepeatWrapping or MirroredRepeatWrapping. Offset/repeat/rotation are texture transforms; atlas animations generally do not need React state per frame.
  • Wrapping, color-space, and upload configuration changes may need texture.needsUpdate. Offset/repeat changes use the texture matrix and do not normally require re-uploading image data.
  • For pixel art, use nearest filtering deliberately. For minified surfaces, mipmaps reduce shimmer; cap anisotropy to the renderer's supported maximum and the scene's needs.
  • Power-of-two dimensions are not a universal WebGL2 requirement. Size textures for screen coverage, memory, compression-format constraints, and quality rather than an obsolete blanket rule.
  • Download size is not GPU memory size. Consider KTX2/Basis where supported; configure renderer capability detection and host decoder/transcoder assets deliberately.
  • For a replacement glTF color map, match the model's UV/orientation conventions; a manually loaded texture commonly needs flipY=false. Do not flip already configured glTF maps again.

Specialized textures

  • Prefer useVideoTexture when its lifecycle fits. Check autoplay/muting, CORS, user gestures, and source cleanup; changing video resolution may require a new texture. Do not promise autoplay succeeds on every browser.
  • Canvas/DataTexture content changes need needsUpdate; data textures should keep data color-space semantics. Creating a texture in a frame loop leaks work/resources unless deliberately managed.
  • For render targets, read offscreen rendering. Never sample from a texture while rendering into that same target.
  • Keep environment maps on a lighting path (Environment/useEnvironment) rather than assigning a regular 2D image without a suitable mapping/PMREM workflow.

Verify

Test a known color swatch, data maps under changing lights, texture orientation, repeated mounts, and two consumers with different UV transforms. Inspect GPU texture counts; they are counts, not byte-accurate memory measurements.

Sources