From 12ec4e8284afb30ed894d9926362141cdfb24b96 Mon Sep 17 00:00:00 2001 From: Keuin Date: Tue, 3 May 2022 15:59:11 +0800 Subject: Refactor: do not invert ri in constructor of material_dielectric. Rewrite material_dielectric::scatter to stop using vec3::refract and switch to ri instead of ri_inv. --- material_dielectric.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'material_dielectric.h') diff --git a/material_dielectric.h b/material_dielectric.h index 46b17da..14cd680 100644 --- a/material_dielectric.h +++ b/material_dielectric.h @@ -9,7 +9,7 @@ #include "material.h" class material_dielectric : public material { - double ri_inv; + double ri; // refractive index, 1.0 for air and 1.5 for glasses static double reflectance(double cosine, double ref_idx) { assert(cosine > 0); @@ -21,7 +21,7 @@ class material_dielectric : public material { } public: - explicit material_dielectric(double ri) : ri_inv{1.0 / ri} {} + explicit material_dielectric(double ri) : ri{ri} {} bool scatter(ray3d &r, const object &hit_obj, double hit_t, random_uv_gen_3d &ruvg) const override; }; -- cgit v1.2.3