Examples Materials


In 3D rendering, a material determines how a surface responds to light. p5’s WEBGL mode supports ambient, emissive, normal, and specular materials.

An ambient material responds to ambient light only. A specular material responds to any light source. In p5, an emissive material displays its color regardless of light source. In other contexts, typically an emissive material emits light. A normal material visualizes the direction each part of the surface faces. A normal material does not respond to light.

Ambient and emissive materials can be combined with each other. They can also be combined with fill and stroke. Fill sets a base color for the surface, and stroke sets the color for the object’s vertices.

Additionally, texture() wraps an object with an image. The model and image texture in this example are from NASA’s collection.