New scatter formula

This commit is contained in:
Phireh 2021-08-21 22:39:59 +02:00
commit 2e24fef5ac
2 changed files with 17 additions and 1 deletions

View file

@ -159,4 +159,20 @@ vec3 random_in_unit_sphere()
}
}
// Returns a normalized version of the above vector
vec3 random_unit_vector()
{
return normalize(random_in_unit_sphere());
}
vec3 random_in_hemisphere(const vec3& normal)
{
vec3 in_unit_sphere = random_in_unit_sphere();
if (dot(in_unit_sphere, normal) > 0.0)
return in_unit_sphere;
else
return -in_unit_sphere;
}
#endif