diff options
Diffstat (limited to 'material.cpp')
-rw-r--r-- | material.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/material.cpp b/material.cpp index f92b02c..b312246 100644 --- a/material.cpp +++ b/material.cpp @@ -18,16 +18,21 @@ bool material_diffuse_lambertian::scatter(ray3d &r, const object &hit_obj, doubl return true; } -material_diffuse_lambertian::material_diffuse_lambertian(double albedo) : albedo(albedo) { - assert(albedo >= 0); - assert(albedo <= 1); +material_diffuse_lambertian::material_diffuse_lambertian(vec3d albedo) : albedo(albedo) { + assert(albedo.mod2() >= 0); + assert(albedo.mod2() <= 1); } -material_diffuse_simple::material_diffuse_simple(double albedo) : albedo(albedo) { +material_diffuse_lambertian::material_diffuse_lambertian(double albedo) : albedo{albedo, albedo, albedo} { assert(albedo >= 0); assert(albedo <= 1); } +material_diffuse_simple::material_diffuse_simple(vec3d albedo) : albedo(albedo) { + assert(albedo.mod2() >= 0); + assert(albedo.mod2() <= 1); +} + bool material_diffuse_simple::scatter(ray3d &r, const object &hit_obj, double hit_t, random_uv_gen_3d &ruvg) const { const auto hit_point = r.at(hit_t); // hit point, on the surface auto nv = hit_obj.normal_vector(hit_point); @@ -41,11 +46,16 @@ bool material_diffuse_simple::scatter(ray3d &r, const object &hit_obj, double hi return true; } -material_diffuse_hemispherical::material_diffuse_hemispherical(double albedo) : albedo(albedo) { +material_diffuse_simple::material_diffuse_simple(double albedo) : albedo{albedo, albedo, albedo} { assert(albedo >= 0); assert(albedo <= 1); } +material_diffuse_hemispherical::material_diffuse_hemispherical(vec3d albedo) : albedo(albedo) { + assert(albedo.mod2() >= 0); + assert(albedo.mod2() <= 1); +} + bool material_diffuse_hemispherical::scatter(ray3d &r, const object &hit_obj, double hit_t, random_uv_gen_3d &ruvg) const { const auto hit_point = r.at(hit_t); // hit point, on the surface @@ -59,3 +69,8 @@ material_diffuse_hemispherical::scatter(ray3d &r, const object &hit_obj, double r.direction((diffuse_target - hit_point).unit_vec()); // the new diffused ray we trace on return true; } + +material_diffuse_hemispherical::material_diffuse_hemispherical(double albedo) : albedo{albedo, albedo, albedo} { + assert(albedo >= 0); + assert(albedo <= 1); +} |