Sphere Normals

In which you learn how normals on a sphere are practically free.

The normals for a sphere are surprisingly straightforward to calculate. Imagine sending vectors from the sphere's origin to its vertices, like so:

Now imagine the vectors out a little further. These extensions are the normals, and they point in the same direction as the position vectors:

What this means is that you don't need a separate attribute for a sphere's normals. If the sphere is centered on the origin, you can just use the vertex positions themselves as the normals, though you may need to normalize them, as is done in this vertex shader:

in vec3 position;
out vec3 mixNormal;

void main() {
  gl_Position = vec4(position, 1.0);
  mixNormal = normalize(position);

Explore how the normals influence the shading of a sphere in this renderer:

The sphere is made of relatively few triangles. Yet the surface looks surprisingly smooth because the vertices are shared between faces. The shared normals average out the orientations. Smooth shading allows you to significantly reduce the number of triangles in a scene.

Uncheck the checkbox to separate the faces. Each vertex is replaced with four separate vertices. This polygonal style of rendering may evoke feelings of nostalgia among gamers who lived through the 1990s.