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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 KiB

After

Width:  |  Height:  |  Size: 469 KiB

View File

@@ -28,5 +28,14 @@
"diffuse": [0.0, 0.5, 1.0],
"specular": [0.0, 0.0, 0.0]
}
},
"disk": {
"position": [-1.0, 0.0, -3.0],
"normal": [1.0, 0.0, 1.0],
"radius": 3.0,
"material": {
"diffuse": [1.0, 0.5, 0.0]
}
}
}

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;