From 1ed823c4fc7ad137b88019a2fa9f17ae3d10215d Mon Sep 17 00:00:00 2001 From: Keuin Date: Fri, 15 Apr 2022 14:34:46 +0800 Subject: Move diffusive into material_diffusive. Add material_reflective.h. --- material_reflective.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 material_reflective.cpp (limited to 'material_reflective.cpp') diff --git a/material_reflective.cpp b/material_reflective.cpp new file mode 100644 index 0000000..dc38baf --- /dev/null +++ b/material_reflective.cpp @@ -0,0 +1,17 @@ +// +// Created by Keuin on 2022/4/15. +// + +#include "vec.h" +#include "material.h" +#include "material_reflective.h" + +bool material_reflective::scatter(ray3d &r, const object &hit_obj, double hit_t, random_uv_gen_3d &ruvg) const { + const auto hit_point = r.at(hit_t); + const auto nv = hit_obj.normal_vector(hit_point); + const auto reflected = nv.reflect(r.direction()); + r.source(hit_point); + r.direction(reflected); + r.decay(albedo); + return dot(reflected, nv) > 0; +} -- cgit v1.2.3