diff options
author | Keuin <[email protected]> | 2022-04-15 14:06:27 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-04-15 14:06:27 +0800 |
commit | 2d4671d5469116b05709bb1acb614d784d339964 (patch) | |
tree | afa839deea5e01ab3cd062968eae30ca56310370 /material.cpp | |
parent | 50cd8dd3dd029ce432f8e517b4c054e75b5cfe8e (diff) |
Make ray3::decay_ distinguishable between different color channels.
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); +} |