Shading is the process of altering the color of a surface, different shading models capture the process of light reflection on a surface, these models use the following variables in the computation

  • ray (ray) - a ray emitted from a pixel, defined with an origin (rayorigin) and a direction raydirection
  • p (intersection point) - the intersection point of the surface and ray
  • l (light direction) - a unit vector pointing from the surface towards a light source, computed by normalizing the vector between the intersection point p and the light source position ls
l=lsβˆ’p|lsβˆ’p|

  • v (view direction) - a unit vector pointing from the surface towards the place the ray is emitted from, it’s computed by normalizing the vector between the intersection point p and the ray origin rayorigin
v=rayoriginβˆ’p|rayoriginβˆ’p|

  • n (surface normal) - a unit vector perpendicular to the surface at the point where the reflection is taking place
  • other characteristics of the light source and the surface depending on the shading model