3D geometry in p5.js needs a light source to convey shape and depth; ambient vs directional/point light differ
In p5.js WEBGL mode, light is an essential part of a 3D scene, helping convey shape and depth — without a light, materials read flat. ambientLight() brightens everything uniformly with no consideration for light position or direction, so it alone leaves surfaces evenly lit and shapeless. directionalLight() shines from a single angle, and pointLight() emits from a single point in all directions; both create shading that reveals form because faces angled toward the light appear brighter. Materials respond to light: ambientMaterial() mixes with the diffuse component while specularMaterial() adds reflected highlights (its shininess set by shininess()).
Examples
function draw() { background(0); ambientLight(60); directionalLight(255, 255, 255, 0.5, 0.5, -1); ambientMaterial(200, 100, 100); sphere(80); // now shaded, showing curvature }
Assessment
You add a sphere() in WEBGL but it looks like a flat disc. Explain why, and which light types would reveal its curvature. Distinguish ambientLight from directionalLight.