a few question regarding the ray tracing algorithm:
it gets the first object that intersects with the ray
(if there are no intersections it goes out)
then if the object is reflective it sends recursively a reflection ray and compute the color of it.
if the object is transparent it sends recursively a refraction ray and compute the color of it .
what is the last line?:
return shade(reflactColor, refractColor,p,obj)
does it compute a color by doing an average of the values of reflectColor and refractColor or something like that ?
2 . where is the shadow ray? is it not part of the algorithm
3 . and last thing.. why do we need to have it recursive?
You seem to have a good grasp on the algorithm.
The last line does look like it is computing some sort of weighted combination of the reflected and refracted colors.
Also, you are correct that the shadow ray tracing is not included in the basic algorithm you attached in your post. However, it is easily added by shooting a ray to the light source and determining if there is an intersection between the object you hit and the light. If there is, then the light is occluded and the object should not be lit at that point.
To explain the recursion, one can think of a pair of mirrors facing each other. You would get the infinite mirror effect (in real life). If you did not recurse and only cast reflective/refractive rays once, your virtual mirrors (or reflective surfaces in general) would only appear to reflect the other objects, and not the other objects' reflections as well. (So, no infinite mirror effects. :( )