Fixed a bug with the fresnel term.

This commit is contained in:
2017-02-10 03:52:31 -04:00
parent 0cdc7c46ca
commit 79b2aa4553
3 changed files with 12 additions and 1 deletions

View File

@@ -11,7 +11,9 @@ const vec3 BCKG_COLOR = vec3(0.1f);
float Tracer::fresnel(const vec3 & i, const vec3 & n, const float ir1, const float ir2) const {
float cos_t1 = dot(i, n);
float cos_t2 = dot(normalize(refract(i, n, ir1 / ir2)), n);
float sin_t2 = (ir1 / ir2) * glm::sqrt(1.0f - (cos_t2 * cos_t2));
float cos_t2s = (cos_t2 * cos_t2);
cos_t2s = cos_t2s > 1.0f ? 1.0 : cos_t2s;
float sin_t2 = (ir1 / ir2) * glm::sqrt(1.0f - cos_t2s);
if (sin_t2 >= 1.0f)
return 1.0f;