I am writing a ray tracer. So far, I have diffuse and specular lighting, and I am planning to implement reflection and refraction, too.
So far I have used white lights, where I calculated the surface color like this: surface_color * light_intensity
, divided by the proper distance^2 values, since I am using point light sources. For specular reflection, it's light_color * light_intensity
. Afaik, specular reflection doesn't change the light's color, so this should work with different color light sources, too.
How would I calculate the color reflected from a diffuse surface when the light source is not white? For example, (0.7, 0.2, 0) light hits (0.5, 0.5, 0.5) surface. Also, does distance factor in differently in this case?
Also, how would I add light contributions at a single point from different color light sources? For example, (1, 0.5, 1) surface is lit by (0.5, 0.5, 1) and (1, 0.7, 0.2) lights. Do I simply calculate both (distances included) and add them together?