Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 5.4 — Lights and Their Cost
3D Web · Example 2 of 2

20 point lights: what they add to the shader

Each new light count compiles a new shader program (see programs). Draw calls stay 2: lights add work per pixel, not per mesh.

three.js has six kinds of light, each with its own unit and cost. You learn what they are for, how a point light fades with distance (the decay), and why twenty point lights is a mistake: each light adds work to every pixel.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Choose lights for the showroom: one that makes a shadow, one that keeps shadows from going black. Write the two lines.

02

The pool of light must stop 3 m from a lamp, with the default fading. Which property do you set?

Explain it without notes

01

A point light of 10 cd hangs 4 m above a floor. By what factor does the light on the floor change if it moves to 2 m, and what does decay 0 change?

02

Why do 20 point lights cost more than one, even if only one mesh is in the scene?

20 point lights: what they add to the shader
Press Run to see the page.
idle

Console

Nothing logged yet.

Expected console output

lights  programs compiled so far  newest fragment shader
   1            1          78161 characters
   5            2          81085 characters
  20            3          92104 characters
draw calls: 2 (the same for 1 or 20 lights)