I'm trying to render a screen. So far, I have intersected my rays with the objects in the scene and if there is an intersection, I set a random color to that intersection.
What I need to do next is color pixels according to their values. I have watched more than 10 tutorials, read several websites about coloring the pixels. However, the file I'm reading does not have colors of the objects. Instead it has the following:
- An ambient light, with rgb color
- A point light, with rgb color and position
- Objects have ambient, diffuse, specular, mirror reflectance(in rgb) and a phong exponent(a value).
Also, I know that the intensity of the light emitted is proportional to the square of the distance(as distance becomes larger, there is less light on an object).
If I had the color of the object, I could use the algorithm below:
Color3 trace(..)
{
...
Color3 ambient = object.color * 0.3;
Color3 phong = phongModel(..) or object.color;
Color3 reflection = trace(..);
return ambient + phong + reflection;
}
as in stated in: How to compute reflected color?
I don't have the color of the object, just reflectance values. How can I calculate the color of the object?