title: Calculating Diffuse (Lambertian) Reflection
body: <p>l need help figuring out how to calculate (Lambertian) diffuse reflectance - that is when a light ray hits a surface and then bounces off in a random direction. So if I have a light vector L originating from the light source, a 3D point X and a normal vector N at point X, how do I calculate a randomly reflected ray?</p>
  
  <p>In one book I am reading on the subject they say to use this equation:</p>
  
  <p>Wd = (theta, phi) = cos-1(sqrt(rand1), 2*pi*rand2) where Wd is the reflected ray, and rand1 and rand2 are random numbers in the range [0,1].</p>
  
  <p>This didn't work for me. I used that equation and then converted the spherical coordinates to cartesian coordinates but this made it so the rays were always being reflected in the same few directions, regardless of the orientation of the normal.</p>
  
  <p>Any help is appreciated!</p>