diff --git a/output.png b/output.png index a921ad4..e498248 100644 Binary files a/output.png and b/output.png differ diff --git a/scenes/scene5.json b/scenes/scene5.json index aa290a3..ca77857 100644 --- a/scenes/scene5.json +++ b/scenes/scene5.json @@ -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] + } } } diff --git a/tracer.cpp b/tracer.cpp index 56465c0..84e1554 100644 --- a/tracer.cpp +++ b/tracer.cpp @@ -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;