All skills
enzed avatar

/r3f-textures

@40d8bcd
by Nicolas Zulloenzed/r3f-skills124 stars
7

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.

Use this Skill: https://skilld.dev/gh/enzed/r3f-skills/r3f-textures

This session only. Nothing lands on disk.

referencesrender-targets.md

≈540 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Offscreen rendering

Use when displaying another scene or rendering intermediate data. This is a WebGL/Drei recipe; WebGPURenderer has different target/pipeline APIs.

Prefer RenderTexture for an isolated scene displayed on a material. It manages its portal and render-target lifecycle. Mount this component beneath Canvas.

import { PerspectiveCamera, RenderTexture } from '@react-three/drei'

export default function SceneOnScreen() {
  return (
    <mesh>
      <planeGeometry args={[3, 3]} />
      <meshBasicMaterial toneMapped={false}>
        <RenderTexture attach="map" width={256} height={256}>
          <color attach="background" args={['navy']} />
          <PerspectiveCamera makeDefault position={[0, 0, 5]} />
          <mesh rotation={[0.3, 0.5, 0]}>
            <boxGeometry />
            <meshBasicMaterial color="coral" />
          </mesh>
        </RenderTexture>
      </meshBasicMaterial>
    </mesh>
  )
}

For manual useFBO work:

  • Render a separate Scene or exclude the surface sampling the target. Sampling the same texture currently attached for writing creates a GPU feedback loop; iterative simulations require ping-pong targets.
  • Save the previous target with gl.getRenderTarget() and restore it in finally. Restore viewport/scissor/clear state if you changed them; do not blindly reset to null in nested pipelines.
  • Schedule the offscreen pass before its consumer, without unintentionally taking over the final frame render. Coordinate with the composer.
  • Size targets for their use rather than always using full screen/DPR. Resize deliberately; choose color/depth formats appropriate for the data and device.
  • Preserve linear intermediate data and apply final output conversion once. A rendered color image and a numeric simulation texture have different semantics.
  • useFBO owns its target lifecycle. A manually constructed target needs cleanup; dispose targets after their last consumer is gone.

Sources: RenderTexture, useFBO, WebGLRenderTarget.

Source: SKILL.md on GitHub

1 warning18d5 checks · Risk SAFE
  • Gen Agent Trust Hub18d

    The skill provides legitimate technical guidance and code examples for managing textures and offscreen rendering in React Three Fiber. No malicious patterns, obfuscation, or unauthorized data access were found.

  • Socket18d

    No alerts

  • Snyk18d

    Risk: LOW · No issues

  • Runlayer7mo

    1/1 file flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 40d8bcd. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated last month

README badge

README badge for enzed/r3f-skills/r3f-textures