Materials, Colors, and Lights

Learn Basic and Standard materials and common lights, and understand opacity, metalness, roughness, and shadows.

🎯 Introduction

By the end of this article, you will be able to choose materials and lights, set color, opacity, metalness, and roughness, and make objects cast controllable shadows onto the ground.

🧱 Materials define surface appearance

MeshBasicMaterial does not calculate lighting. It suits solid-color markers, debugging, and objects that do not need shading. MeshStandardMaterial uses a more realistic lighting model, making it suitable for products, models, and most lit scenes.

const basic = new THREE.MeshBasicMaterial({ color: 0x6699ff });
const standard = new THREE.MeshStandardMaterial({
    color: 0x6699ff,
    roughness: 0.45,
    metalness: 0.15,
});
  • color is the base color; the final rendered color may differ.
  • roughness describes surface roughness. Lower values produce tighter highlights.
  • metalness describes how metallic the surface is. Metals rely more on environment reflections.
  • opacity controls transparency when transparent: true is enabled.
const glass = new THREE.MeshStandardMaterial({
    color: 0x99ddff,
    transparent: true,
    opacity: 0.45,
    roughness: 0.1,
});

Setting wireframe: true displays triangle edges. This is useful for inspecting geometry, but is generally not intended as the final appearance.

💡 Common lights

  • AmbientLight illuminates all objects uniformly, without direction or shadows.
  • HemisphereLight provides soft ambient fill using sky and ground colors.
  • DirectionalLight shines from one direction like sunlight and works well as a key light.
  • PointLight emits light in all directions from a point like a bulb, usually becoming dimmer with distance.

A useful starting point is ambient fill plus a directional light for shading:

scene.add(new THREE.HemisphereLight(0xffffff, 0x445566, 1.5));

const keyLight = new THREE.DirectionalLight(0xffffff, 2);
keyLight.position.set(3, 5, 4);
scene.add(keyLight);

This demo compares the unlit Basic material with the Standard material, which responds to lighting:

Observe the effect of enabling shadows in this rendered example:

🪤 Minimal shadow configuration

Shadows require settings on the renderer, light, and objects:

renderer.shadowMap.enabled = true;
keyLight.castShadow = true;

cube.castShadow = true;
ground.receiveShadow = true;

These four settings have separate roles: the renderer enables shadow rendering, the light casts shadows, the object casts its shadow, and the ground receives it. Enabling just one is not enough to produce the complete shadow.

Shadows add rendering cost. Start with key objects casting shadows, and adjust keyLight.shadow.mapSize if edges look jagged. Avoid enabling shadows on every object from the outset.

MeshStandardMaterial also needs environment reflections to convey a full metallic appearance. With only one direct light, a metal object may simply look darker.

🧾 Summary

  • Basic materials ignore lighting; Standard materials calculate it.
  • roughness controls highlight spread, and metalness controls metallic behavior.
  • Ambient lights provide fill, while directional and point lights give objects depth.
  • Shadows require the corresponding renderer, light, and mesh settings.
  • More lights are not always better. Establish the roles of key and fill lights first.

❓ Questions and answers

Q1: Why does a Standard material look black?

The scene usually lacks effective lighting, or light positions and intensities are unsuitable. Start troubleshooting with an ambient light and a directional light.

Q2: Why do transparent objects look wrong?

Set both transparent: true and opacity, and check transparent-object draw order and occlusion.

Q3: Why are there no shadows even with lights?

Check the renderer's shadowMap, the light's castShadow, the casting object's castShadow, and the receiving surface's receiveShadow.

🧪 Exercise

Create two spheres: one with low roughness and low metalness, and one with high roughness and high metalness. Compare their highlights under the same lights.

// Write your code here

🎉 Materials and lights shape the scene's appearance. Next, you will add images to surfaces for patterns and realistic detail.