Thursday, September 27, 2012

Diffuse lambertian surfaces


Lambert's Cosine Law: It states that the intensity of light on a diffuse surface is directly proportional to the cosine angle θ between the incoming light ray and the unit normal to the surface.
In layman's language, if the angle is low light intensity is low and if angle is high intensity is high.

Hence, applying lambert's law in ray tracer code will give diffuse lambertian surfaces.

Pseudocode:

float lambert = (lightRay.direction * normal) * coef;
colors += currentMat.color * light.color * lambert ;


Images generated after its application: (although shadows seem wrong)




No comments:

Post a Comment