0
votes

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?

1
Why not just assume a default color for objects (e.g.: white)?UnholySheep
Well, good assumption. It might be this, I'm going to try this. I feel like an idiot for not thinking thisGff8811
It is better to try a gray rather full than white, so you can see "reflections"Raxvan

1 Answers

1
votes

However, the file I'm reading does not have colors of the objects. Instead it has the following:

...

  • Objects have ambient, diffuse, specular, mirror reflectance(in rgb) and a phong exponent(a value).

If you have RGB far all these, that is the color of the object.

Multiply incoming light with how the object reflects it in given angles and the result is the color by which it is perceived.