Wolfram: Lighting
xtodo work in progress
Lighting Intro
Lighting interacts with Surface Color.
Lighting have many possibilities:
- Lighting can have multiple light sources.
- Each light source can be in different position. It can be fixed relative to the object, or can be fixed relative to the viewing screen, so that rotating the object changes its shadow.
- Each light source can have different color.
- Each light source can be different type.
DirectionalLight
light (like sun light)SpotLight
(like a flashlight)PointLight
(like a lamp)AmbientLight
(like in a well-lit room)
- Some light source can attenuate by distance to object.
Also, surface normals can be set to arbitrary function so the object reflect light in a non-standard way.
Specify Lighting
Lighting can be specify in 2 ways:
Local Lighting Per Graphics Primitive
As a Graphics Directive attached to the Graphics Primitive.
Global Lighting
As the option Lighting
for Graphics3D
, Plot3D
, ParametricPlot3D
etc.
Lighting (Global Lighting)
Lighting
-
Lighting -> None
→ no light.Lighting -> LightSource
→ a light source.Lighting -> {LightSource1, LightSource2, etc}
→ multiple sources.
Lighting are Graphics Directives

(* Light directive can be attached to each graphics primitive. Torus, on the left. cyan light, from left of screen. Sphere, on middle. red light, from top of screen. Cylinder, on the right. green light, from right of screen. *) Graphics3D[ { Style[Torus[{-2,0,0},{1,2}] , DirectionalLight[Cyan, ImageScaled[{-1, 0, 0}] ]], Style[Sphere[{0,0,0},1] , DirectionalLight[Red, ImageScaled[{0, 1, 0}] ]], Style[ Cylinder[{{2,0,0}, {2,0,3}},1] , DirectionalLight[Green, ImageScaled[{1, 0, 0}] ]] }, Axes -> True, SphericalRegion -> True, Lighting -> None ]
DirectionalLight
DirectionalLight
-
Like sun light. Parallel rays.
Direction light is great way to show complex shape, because it is simple, and it cast shadows, to give cue of the shape.
One way is to use a single direction light, and have the light source fixed relative to the viewing screen, so that rotating the object changes its shadow. Use
ImageScaled[{1, 1, 1}]
as coordinate to fix the light source to the viewing screen.wl DirectionalLight 2025-06-28 283d6 Graphics3D[ {Sphere[{0,0,0},1], Torus[{-2,0,0},{1,2}], Cylinder[{{2,0,0}, {2,0,3}},1] }, Axes -> True, SphericalRegion -> True, Lighting -> DirectionalLight[Red, ImageScaled[{1, 1, 1}] ] ]
Example
wl DirectionalLight 2025-06-29 17286 ParametricPlot3D[ {Cos[u]*(2 + Cos[v]), Sin[u]*(2 + Cos[v]), Sin[v]} , {u, 0, 5}, {v, 0, 6}, SphericalRegion -> True, ColorFunction -> Function[x, White], Lighting -> DirectionalLight[White, ImageScaled[{1, 0, 0}]] ]
PointLight
PointLight
-
Like from a light bulb.
wl PointLight 2025-06-28 284c3 Graphics3D[ {Sphere[{0,0,0},1], Torus[{-2,0,0},{1,2}], Cylinder[{{2,0,0}, {2,0,3}},1] }, Axes -> True, SphericalRegion -> True, Lighting -> PointLight[White, {0, 0, 3}] ]
SpotLight
SpotLight
-
Like a flashlight. Rays from a point, and conical spread. No light outside of the cone.
wl SpotLight 2025-06-28 28551 Graphics3D[ {Sphere[{0,0,0},1], Torus[{-2,0,0},{1,2}], Cylinder[{{2,0,0}, {2,0,3}},1] }, Axes -> True, SphericalRegion -> True, Lighting -> SpotLight[Green, {0, 0, 3}, 60 Degree] ]
AmbientLight
AmbientLight
-
Surrounding light, from all directions. Cast no shadows.
wl AmbientLight 2025-06-28 28395 Graphics3D[ {Sphere[{0,0,0},1], Torus[{-2,0,0},{1,2}], Cylinder[{{2,0,0}, {2,0,3}},1] }, Axes -> True, SphericalRegion -> True, Lighting -> AmbientLight[Red] ]
Wolfram AmbientLight 2025-06-20 19af2 Plot3D[Sin[x] Cos[y] (x y), {x, 0, 3 Pi}, {y, 0, 3 Pi}, ColorFunction -> Function[x, White], Lighting -> AmbientLight[Red] ]