CNA Samples

Vertex Lighting

Ported from Microsoft's XNA 4.0 Vertex Lighting sample.

Source for this sample on GitHub ↗

A blue sphere shaded by directional and ambient light above a green reference grid. Play ▸

Opens in a new tab. Toggle flat shading and vertex lighting, then change the mesh.

About this sample

Compare an unlit white effect with directional and ambient light calculated at each vertex. The vertex colors are interpolated across the mesh, producing smooth Gouraud shading. Try the sphere, cylinder, cone and cube to see how the geometry changes the result.

Controls

ActionKeyboardGamepad
Toggle lighting effectSpaceY
Next meshTabX
Rotate meshArrow keysLeft stick
Orbit cameraW, A, S, DRight stick
ZoomZ and XA and B
ExitEscapeBack