Atlaslog
Atlaslog / three.js / Tutorial / Materials and lighting
three.js · Tutorial

Materials and lighting

Quick answer

This tutorial explains how MeshStandardMaterial responds to light through roughness and metalness, and why MeshBasicMaterial flattens terrain relief. It assembles a practical outdoor rig from HemisphereLight, a shadow-casting DirectionalLight and a weak fill light, with shadow map size, camera bounds and bias configured. It notes the physical light units introduced in r155 and the sRGB versus linear texture split. Readers can light a city model without washed-out colors or missing shadows.

Last verified 2026-11-03 · three.js 0.160.0 · Cite this page
Key points
Example
const material = new THREE.MeshStandardMaterial({
  color: 0x9aa7b4,
  roughness: 0.85,   // 粗糙,接近混凝土
  metalness: 0.05,   // 非金属
  map: colorTexture, // 基础色贴图
  normalMap: normalTexture,
  side: THREE.FrontSide
});
scene.add(new THREE.HemisphereLight(0xcfe4ff, 0x1a222c, 1.0));
const sun = new THREE.DirectionalLight(0xfff0d8, 2.4);
sun.position.set(8, 14, 6);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -30;
sun.shadow.camera.right = 30;
sun.shadow.camera.top = 30;
sun.shadow.camera.bottom = -30;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 80;
sun.shadow.bias = -0.0005;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x8fb4ff, 0.6);
fill.position.set(-10, 6, -8);
scene.add(fill);
Notes
Runnable examplesChinese originalAll Tutorials
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Materials and lighting. https://www.jingweizhi.com/en/three/tutorials/materials-lights.html (accessed 2026-11-03).