Refraction requires the generation of a secondary ray when a ray strikes a refractive (transparent) surface (defined by its material). The ray is calculated using Snell's law and the index of refraction defined by the material. The colour obtained by the refracted ray is scaled according to the parameters of the material of the surface and added to a scaled version of the direct colour at the intersection. Recursion depth is controlled by a command line parameter.
Glass balls (index of refraction 1.22) with secondary ray recursion depth of 3.