pbr-materials-and-lighting
БесплатноБез исполняемых скриптовНе проверенMake three.js PBR materials look right: color management (sRGB output, which textures are sRGB and which are linear), tone mapping (AgX, Neutral, ACES Filmic)…
от nirholas★ 289 звёзд на GitHubОб этом скилле
PBR materials and lighting in three.js
Targets three.js r187 ([email protected]). Every runnable block is executed in Chromium before
this plugin ships.
Most "my model looks wrong" reports come from four settings, in this order of frequency:
- No environment. PBR materials reflect their surroundings. With only a
DirectionalLight, metal has nothing to reflect and renders black, and everything looks flat. Setscene.environment. - A color texture tagged as linear. Base color and emissive maps are sRGB. Normal,
roughness, metalness and AO maps are linear data.
GLTFLoadertags them for you; textures you load yourself must be tagged by hand. - No tone mapping. Lit scenes produce values above 1.0. Without a tone mapper they clip
to white.
ACESFilmicToneMapping,AgXToneMappingandNeutralToneMappingroll them off. - Exposure left at the default after switching tone mapper or environment.
Color management is on by default since r152 (THREE.ColorManagement.enabled === true) and
renderer.outputColorSpace defaults to THREE.SRGBColorSpace. Leave both alone. The old
names were renderer.outputEncoding = THREE.sRGBEncoding and texture.encoding; both were
removed in r162. renderer.useLegacyLights (physically incorrect light units) was removed in
r165, so intensities are physical: a DirectionalLight intensity is in lux-like units and a
PointLight is in candela with real distance falloff.
1. A correct lit scene, and how roughness and metalness respond
The grid below sweeps roughness left to right and metalness bottom to top under a
RoomEnvironment. Use it to calibrate expectations before blaming a model.
import * as THREE from 'three';
import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.toneMapping = THREE.AgXToneMapping;
renderer.toneMappingExposure = 1;
document.body.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x202124);
// Image-based lighting: PMREMGenerator prefilters the environment once so every
// roughness level samples a correctly blurred reflection.
const pmrem = new THREE.PMREMGenerator(renderer);
scene.environment = pmrem.fromScene(new RoomEnvironment(), 0.04).texture;
pmrem.dispose();
// A color texture you build or load yourself must be tagged as sRGB.
const canvas = document.createElement('canvas');
canvas.width = canvas.height = 256;
const ctx = canvas.getContext('2d');
for (let i = 0; i < 8; i++) {
for (let j = 0; j < 8; j++) {
ctx.fillStyle = (i + j) % 2 ? '#d94f30' : '#f2e8cf';
ctx.fillRect(i * 32, j * 32, 32, 32);
}
}
const checker = new THREE.CanvasTexture(canvas);
checker.colorSpace = THREE.SRGBColorSpace;
checker.anisotropy = renderer.capabilities.getMaxAnisotropy();
const geometry = new THREE.SphereGeometry(0.4, 64, 32);
const steps = 5;
for (let m = 0; m < 3; m++) {
for (let r = 0; r < steps; r++) {
const material = new THREE.MeshStandardMaterial({
color: m === 2 ? 0xffffff : 0xc9a227,
map: m === 2 ? checker : null,
metalness: m === 1 ? 1 : 0,
roughness: r / (steps - 1),
});
const sphere = new THREE.Mesh(geometry, material);
sphere.position.set((r - (steps - 1) / 2) * 1, (m - 1) * 1, 0);
scene.add(sphere);
}
}
const camera = new THREE.PerspectiveCamera(35, window.innerWidth / window.innerHeight, 0.1, 100);
camera.position.set(0, 0, 8);
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
renderer.setAnimationLoop(() => renderer.render(scene, camera));
What to notice: the top row (metalness 0 with a texture) keeps its colors under AgX; the bottom row is the same gold as a dielectric (colored diffuse, white highlights); the middle row (metalness 1) is pure reflection, so it is only as interesting as the environment; roughness 0 spheres show a sharp room, roughness 1 shows a soft gradient. If your model's metal looks black, it is the middle row without an environment.
Rules of thumb for authored values:
- Metalness is binary in nature: 0 for dielectrics (wood, plastic, skin, stone), 1 for bare metal. Values in between are for blending masks, not for "a bit shiny".
- Pure black or pure white base colors do not occur in nature. Keep albedo between about
0x1e1e1eand0xf0f0f0. - Need clear coat, sheen (fabric), transmission (glass), iridescence or physical IOR? Use
MeshPhysicalMaterial. It costs more per pixel, so use it only on the meshes that need it.
2. Light with a real HDR environment
RoomEnvironment is a neutral studio built in code. For a specific mood, load an
equirectangular .hdr. This one is CC0 from Poly Haven and served with open CORS.
Установить pbr-materials-and-lighting в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл pbr-materials-and-lighting?
Make three.js PBR materials look right: color management (sRGB output, which textures are sRGB and which are linear), tone mapping (AgX, Neutral, ACES Filmic) and exposure, image-based lighting from RoomEnvironment or an HDR file through PMREMGenerator, and how roughness and metalness actually respond. Use when a model looks washed out, too dark, flat, plasticky, over-saturated or black; when colors do not match the reference or Blender; when metal looks black; or when the user asks how to light a scene, add an HDRI or environment map, or pick a tone mapper.
Как установить скилл pbr-materials-and-lighting?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл pbr-materials-and-lighting запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic