Fixed a bug with the fresnel term.
This commit is contained in:
BIN
output.png
BIN
output.png
Binary file not shown.
|
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 469 KiB |
@@ -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]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user