= Solution
For single-shot <ray tracing (computer graphics)>, construct one primary <ray> per <pixel>, normally through its centre on the image plane, with the camera centre as origin for <perspective projection>. Transform the <ray> into the scene's coordinates, or consistently transform all the scene geometry into camera coordinates.
Intersect that primary <ray> with the scene's <triangles>, using part (c), and retain the accepted hit with the smallest nonnegative parameter $\lambda$. This nearest-hit selection supplies visibility: farther surfaces cannot show through the first opaque surface. If there is no hit, write the background colour. At a hit $p$, obtain its material colour and front <unit normal vector> and set $\hat V$ toward the camera.
For each point light at $\ell_j$, form $\hat L_j=(\ell_j-p)/\|\ell_j-p\|$, calculate the <specular reflection> direction, and evaluate its diffuse and specular contributions using the <Phong reflection model>. Sum the contributions and add ambient illumination once:
$$
\boxed{I(p)=k_aI_a+\sum_j I_j(p)\left[k_d\max(0,\hat N\cdot\hat L_j)+k_s\chi_j\max(0,\hat R_j\cdot\hat V)^n\right].}
$$
The coloured surface can supply colour-dependent diffuse weights, and each source can have its own colour. Convert the result into the output image's colour encoding and range. Single-shot here means direct local shading after one primary visibility <ray>; no reflected or transmitted secondary viewing rays are followed. Part (e) adds secondary visibility queries for the lights.
Back to article page