# question about true Lambertian reflection in Ray tracing in one weekend

I have a question about Peter Shirley's Ray tracing in one weekend. In the True Lambertian Reflection section, when talking about rejection method, he said

This distribution scales by the cos^3(ϕ) where ϕ is the angle from normal

Can anyone please tell me where the exponent 3 comes from? Thanks!

• See the following (it may be fairly confusing however): github.com/vchizhov/Derivations/blob/master/… Sep 26, 2021 at 15:59
• @lightxbulb Thanks for the link. But yes, it is a bit confusing... Sep 29, 2021 at 10:15

There are two different methods of computing a random ray bounce being compared in this section of the online book, the first one is: Pick a point $$s$$ anywhere inside the sphere, then compute a vector from a point $$p$$ on the surface to the point $$s$$ inside the sphere.

The second method is: Pick a point $$s$$ anywhere on the surface of the sphere, then compute a vector from the point $$p$$ to the point $$s$$ on the surface of the sphere.

After computing the random vector, compute the angle $$\phi$$ between the given normal vector and random vector. That angle is then used in the lighting computations.

Given the two methods of computing a random vector the question arises: "Are these two methods equivalent and how do we show that they are or are not?" To show that we have to somehow compute every possible angle using the two different methods which should result in a function they are equivalent to. The bit of language "every possible angle" suggests using integrals over a volume for the first method and integrals over a surface for the second method. And that is where these two approaches diverge, the integration over the volume gives a different answer then the integration over the surface.

...skipping all the math...

The first method it turns out, after doing a bunch of calculus, is equivalent to $$cos^3(\phi)$$ suggesting that all those points on the interior of the sphere are skewing the random vector angle towards the center of the sphere which are close to the normal vector.

The second method, after a bit more calculus, gives the result $$cos(\phi)$$ which is the answer we were hoping for.

• Thank you so much for your explanation. It's exactly what I want. Oct 6, 2021 at 15:47

I think it is a mistake in the book.

Pick random points uniformly on a sphere offset by the normal, you will get a distribution of rays proportional to $$\cos{\theta} \sin{\theta}$$, rather than $$\cos{\theta}$$ as the book written.

$$ds = \frac{(2r \cdot \cos{\theta} \cdot d\theta) }{\cos{\theta}} \cdot (2 \pi \cdot 2r \cdot \cos{\theta} \sin{\theta)}$$ where $$ds$$ is the differential area on the shifted sphere's surface with respect to $$\theta$$. Integrate $$\theta$$ from 0 to $$\pi/2$$, you'll get $$4 \pi r^2$$.

And pick random points uniformly inside a sphere offset by the normal, you obtain a distribution of rays proportional to $$\cos{\theta}^3 \sin{\theta}$$.

$$dv = (2r \cos{\theta} d\theta) \cdot(2\pi \cdot 2r \cos{\theta} \sin{\theta}) \cdot(2r \cos{\theta} \cdot \frac{1}{3})$$ where $$dv$$ is the differential volume (whitch is a quadrangular pyramid) with respect to $$\theta$$ inside the sphere. You can readily integrate it to $$\frac{4}{3} \pi r^3$$.