CNA Samples

Per-Pixel Lighting

Ported from Microsoft's XNA 4.0 Per-Pixel Lighting sample.

Source for this sample on GitHub ↗

A shaded sphere over a green reference grid, with the lighting technique and specular settings at upper left. Play ▸

Opens in a new tab. Switch between five lighting modes and five meshes.

About this sample

Compare diffuse and Phong lighting calculated at vertices or at pixels. Switch among a high-resolution sphere, low-resolution sphere, cylinder, cone and cube to see how mesh geometry changes the result. You can also adjust the specular highlight and move the camera.

Controls

ActionKeyboardGamepad
Next lighting modeSpaceY
Next meshTabX
Rotate meshArrow keysLeft stick
Move cameraW, A, S, DRight stick
ZoomZ and XTriggers
Specular powerNumeric keypad * and /D-pad left and right
Specular intensityNumeric keypad + and −D-pad up and down
ExitEscapeBack