More 3D graphics

Progress notes on advancing the teapot rendering pipeline: normals, culling, lighting and shading techniques.

Introduction

After the teapot wireframe, the next steps were focused on improving surface handling and lighting. See the teapot source for the progress stages.

Teapot: patch & progress

Teapot wireframe

Face culling

With Bezier patches we calculate per-vertex normals using:

n = normalize(cross(v0, v1)); where v0 and v1 are the triangle sides.

This removes many back faces, although additional logic is needed to handle complex patches.

Face culling code

Light model

Applying a light model per-face yields flat shading. The next steps interpolate normals for smoother shading models.

Flat shading example

Light model source

Shading

Interpolating vertex values produces Gouraud shading; interpolating normals enables Phong shading for more realistic highlights.

Shading example

Shading experiments

Z-buffer

After implementing a Z-buffer the model correctly displays occlusion: the teapot lid and handle render as expected.

Z-buffer result

Z-buffer code

Rendering

Final rendering includes textures and more complex lighting; the video below shows the textured teapot with updated lighting.