Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should the random_on_hemisphere() function be used for Lambertian reflection in section 9.4? #1574

Open
whenyd opened this issue Jun 20, 2024 · 1 comment
Milestone

Comments

@whenyd
Copy link

whenyd commented Jun 20, 2024

When I read the new line of code:
vec3 direction = rec.normal + random_unit_vector();
I'm confused. According to the descreption, we want to select the tangent unit sphere that is on the same side of the surface as the ray origin.
The random_on_hemisphere() function takes into account the reflection on the side of the incident light, while the random_unit_vector() function may get the light pointing inside the sphere.
And I got a picture more shadow under the small sphere. But I'm sorry the picture failed to upload.

@PoneyUHC
Copy link

rec.normal points outside the sphere if the incoming ray hits the sphere from outside.
It is also normalized, ie it has a magnitude of 1.
If you add a random_unit_vector to it, the result is on a unit_sphere outside the sphere we collide with, but for a single point that is P, which is the point of contact of those 2 spheres.
S will thus always be on this unit sphere outside the colliding sphere, and the vector PS will always be constructed so that its direction is going away from the sphere

@hollasch hollasch added this to the Backlog milestone Jul 19, 2024
@hollasch hollasch modified the milestones: Backlog, v4.0.1 Jul 29, 2024
@hollasch hollasch modified the milestones: v4.0.1, Backlog Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants