Skip to content
Tutorials Center
My learning

Topics

Lesson 13 of 39 ยท Geometry and Materials

Materials: Basic, Lambert, Phong, Toon and Utility

Compare Three.js materials: MeshBasic, Lambert, Phong, Toon, Normal, Depth and Matcap. Learn color, opacity, side, wireframe and when to pick each one.

If the geometry is the skeleton of a mesh, the material is its skin. It decides the color, how shiny the surface is, whether it reacts to light, whether you can see through it, and which side of each triangle is drawn. Three.js offers a family of materials from very cheap to physically accurate. This lesson covers the cheap and utility ones and the properties they all share. The next lesson covers the physically based materials.

Choosing a material

Materials that ignore lights

MeshBasicMaterial Flat color or texture, no shading
MeshNormalMaterial Colors show surface direction
MeshDepthMaterial Grayscale by distance
MeshMatcapMaterial Lighting baked into one image

Great for debugging, UI and very cheap scenes.

1 / 2

The same sphere in every material

The demo lines up one sphere per material under the same lights. Compare how each one handles the highlight.

Material comparison

Observe: Basic is a flat disk, as if cut from paper. Lambert darkens toward the shadow side with a matte look. Phong adds the bright dot, the specular highlight. Toon quantizes light into bands. Normal paints the surface direction as color, and Depth paints distance as gray, controlled by the camera's near and far.

Properties every material shares

These come from the Material base class.

Property Effect
color Base color; a THREE.Color (set with .set("#ff0000"), .set(0xff0000) or .setRGB)
opacity + transparent: true Partial see-through; opacity is ignored unless transparent is true
side FrontSide (default), BackSide, DoubleSide
wireframe Draw triangle edges only
visible Skip drawing the material
depthTest, depthWrite Participate in the depth buffer or not
blending NormalBlending, AdditiveBlending, MultiplyBlending...
alphaTest Discard pixels with alpha below the threshold (cutouts, leaves)
fog Whether the scene fog affects it
vertexColors Use the geometry's color attribute
flatShading Faceted normals (lit materials)
map A color texture (covered in the textures chapter)

After switching a few properties at runtime (such as flatShading, vertexColors or side in some cases) you may need material.needsUpdate = true so Three.js recompiles the shader.

Transparency and sorting

Transparent objects are drawn after opaque ones, sorted from far to near by their center. This is an approximation, and it can fail: two big overlapping transparent shapes may look wrong from some angles. Remedies, in order of preference: avoid transparency where alphaTest (cutouts) is enough; set depthWrite: false on soft transparent particles; split the mesh so sorting works; or use renderOrder to force a draw order.

Opacity, sides, wireframe and blending

Try BackSide: you see the inside faces only, as if looking into a hollow shell. This trick is how skyboxes and room interiors are made: a large sphere or box with BackSide. AdditiveBlending adds the color to what is behind it, which makes glowing effects.

Changing colors at runtime

material.color is a THREE.Color, so use its methods instead of replacing it:

JavaScript
material.color.set("#00ff88");     // CSS name, hex string, or number
material.color.setHSL(0.6, 0.8, 0.5);
material.color.lerp(new THREE.Color("red"), 0.1);   // blend toward red

Sharing a material between many meshes saves memory, but changing it changes all of them. Clone it (material.clone()) when a mesh needs its own variation.

Matcap and toon details

MeshMatcapMaterial needs no lights at all: it samples a small image of a lit sphere, using the surface normal, so the whole look of the shading comes from the picture. It is cheap and gives convincing clay or metal renders. You would load the image as matcap; the textures chapter shows how.

MeshToonMaterial supports a gradientMap: a tiny texture whose pixels define the light bands. Set its filters to NearestFilter so the bands stay sharp.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which material ignores lights completely?

    MeshBasicMaterial draws a flat color or texture, so a scene with no lights still shows it.
  2. 2. You set opacity: 0.3 but the object is still solid. What is missing?

    opacity only has an effect when the material is flagged transparent.
  3. 3. How do you make a large sphere that you can look at from the inside, like a sky dome?

    With BackSide only the inner faces are drawn, so a camera inside the sphere sees the surface.
  4. 4. What is true about a material shared by several meshes?

    Sharing is efficient, but use material.clone() when one mesh needs a different value.

Summary

  • Basic, Normal, Depth and Matcap ignore lights; Lambert, Phong, Toon and Standard need them.
  • Shared properties: color, opacity+transparent, side, wireframe, blending, alphaTest, depthWrite.
  • Transparency is sorted by object center and can look wrong; prefer alphaTest or fix draw order.
  • Use color.set() and share materials wisely; clone when you need an individual change.

Next: PBR Materials: Standard and Physical