PBR 머티리얼

PBR material

금속성(metalness)과 거칠기(roughness) 두 값으로 실제 빛 반사 물리에 가깝게 재질을 표현하는 방식.

다른 이름: Physically Based RenderingMeshStandardMaterialmetalness/roughness
···
js
import * as THREE from 'three';
import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
document.body.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x14141f);
const pmrem = new THREE.PMREMGenerator(renderer);
scene.environment = pmrem.fromScene(new RoomEnvironment(), 0.04).texture;
const camera = new THREE.PerspectiveCamera(40, 1, 0.1, 100);
camera.position.set(0, 0.4, 8.5);
const ROWS = 3, COLS = 5;
const group = new THREE.Group();
for (let row = 0; row < ROWS; row++) {
  for (let col = 0; col < COLS; col++) {
    const metalness = row / (ROWS - 1);
    const roughness = col / (COLS - 1);
    const mat = new THREE.MeshStandardMaterial({ color: 0xc9702e, metalness, roughness });
    const mesh = new THREE.Mesh(new THREE.SphereGeometry(0.55, 48, 48), mat);
    mesh.position.set((col - (COLS - 1) / 2) * 1.35, (row - (ROWS - 1) / 2) * 1.35, 0);
    group.add(mesh);
  }
}
scene.add(group);
const light = new THREE.DirectionalLight(0xffffff, 1.2);
light.position.set(3, 4, 5);
scene.add(light);
function resize() { renderer.setSize(innerWidth, innerHeight); camera.aspect = innerWidth / innerHeight; camera.updateProjectionMatrix(); }
addEventListener('resize', resize); resize();
renderer.setAnimationLoop((t) => {
  group.rotation.y = Math.sin(t * 0.00015) * 0.35;
  renderer.render(scene, camera);
});

PBR(Physically Based Rendering)은 "이 재질이 어떻게 보여야 하는가"를 화가처럼 색을 조합해 정하는 대신, 빛이 표면에서 반사되는 물리 법칙에 가까운 파라미터로 정의합니다. THREE.MeshStandardMaterial의 핵심은 두 값입니다: metalness(0=일반 재질, 1=금속)와 roughness(0=매끈한 거울, 1=완전히 거칢). 이 조합이 옳으면 어떤 조명 아래서도 "그럴듯하게" 보입니다.

데모는 같은 색의 구를 5×3 격자로 늘어놓고 가로축은 roughness를, 세로축은 metalness를 0에서 1까지 바꿉니다. 왼쪽 위(거칠고 비금속)는 무광 플라스틱처럼, 오른쪽 아래(매끈하고 금속)는 거울처럼 보입니다.

금속(metalness=1)은 주변을 비추는 반사광이 없으면 그냥 검게 나옵니다. 그래서 이 데모도 environment-map 항목과 같은 RoomEnvironment + PMREMGenerator로 간단한 조명 환경을 하나 깔아줍니다. 물리 기반 유리·투명 재질처럼 더 세밀한 제어가 필요하면 MeshPhysicalMaterial(MeshStandardMaterial의 상위 확장)로 넘어가세요.

언제 쓰나

제품 렌더, 실사에 가까운 3D UI 요소, 금속/플라스틱/도자기 등 실제 재질을 흉내 낼 때.