Ray Trace - Diffuse lambertian surfaces

This blog explains the implementation details of the 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