-
Notifications
You must be signed in to change notification settings - Fork 945
Closed
Milestone
Description
Which one is the correct one to use?
The book lists this as the code for refract()
:
vec3 refract(const vec3& uv, const vec3& n, double etai_over_etat) {
auto cos_theta = dot(-uv, n);
vec3 r_out_perp = etai_over_etat * (uv + cos_theta*n);
vec3 r_out_parallel = -sqrt(fabs(1.0 - r_out_perp.length_squared())) * n;
return r_out_perp + r_out_parallel;
}
This is what's in the repo right now (https://github.com/RayTracing/raytracing.github.io/blob/master/src/common/vec3.h#L157):
vec3 refract(const vec3& uv, const vec3& n, double etai_over_etat) {
auto cos_theta = fmin(dot(-uv, n), 1.0);
vec3 r_out_perp = etai_over_etat * (uv + cos_theta*n);
vec3 r_out_parallel = -sqrt(fabs(1.0 - r_out_perp.length_squared())) * n;
return r_out_perp + r_out_parallel;
}
It's the fmin()
for cos_theta
. Which one is the correct one to use?
Metadata
Metadata
Assignees
Labels
No labels