Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The right model for shading in Ray tracing

I am wondering about the most accurate way to calculate the shadow generated from several different light sources and ambient light. Ambient light is light that exists in the entire 'world' with the same intensity and no particular direction, and diffused lighting is the lighting that occurs due a direct lighting from a point light source.

Given that Ka is the coefficient for the surface ambient reflectivity, Ia is the intensity of the ambient light, Kd is the surface diffuse reflectivity, Ip1 is intensity of the the first (accordingly) point light source, N is the surface normal, and L1 is the light (of the first source accordingly) direction.

According to my reference material the intensity of the color at the spot should be:

I=Ka.Ia+Kd(Ip1(N.L1)+Ip2(N.L2)) where '.' is the dot product.

But according to my understanding the real light intensity should do some sort of average between the light sources and not just add them up, so that if there are only two light sources the equation should look like:

I=Ka.Ia+Kd(Ip1(N.L1)+Ip2(N.L2))/2

and if there are 3 light sources, but the third is blocked and doesn't light the surface directly then:

I=Ka.Ia+Kd(Ip1(N.L1)+Ip2(N.L2))/3 (so that if there is a place where all 3 lights contribute it would be lighten brighter.

Am I right at my assumption?

like image 756
SIMEL Avatar asked Jan 03 '11 16:01

SIMEL


2 Answers

Well, no, light shouldn't be averaged. Think about it. If you have just one powerful light source, and you add another, very faint light, would the color of the object be diminished? For example say the powerful light has intensity 10, the color (presuming the direction is perpendicular to the normal, and no ambient light, for simplicity sake) would be 10. Then after you add the second faint light, with say intensity 0.1 the color would be (10 + 0.1) / 2 which is 5.05. So adding more light would make the object seem darker. That doesn't make sense.

like image 97
Andrei Fierbinteanu Avatar answered Sep 19 '22 02:09

Andrei Fierbinteanu


In the real world, light adds. It should in your ray tracer, too.

like image 44
Larry Gritz Avatar answered Sep 20 '22 02:09

Larry Gritz