From c5732d64ad481df98041354536c57f60ead8a8c9 Mon Sep 17 00:00:00 2001 From: TheEdgeOfRage Date: Tue, 5 Mar 2024 22:41:00 +0100 Subject: [PATCH] Add normals implementation --- .gitignore | 5 ++++- CMakeLists.txt | 1 + src/normals.cpp | 30 ++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/normals.cpp diff --git a/.gitignore b/.gitignore index c3cf72a..91a0a74 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,7 @@ rules.ninja *.dir *.opendb Debug -x64 \ No newline at end of file +x64 + +*.exr +*.png diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b41d81..52d71c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,7 @@ add_executable(nori src/microfacet.cpp src/mirror.cpp src/dielectric.cpp + src/normals.cpp ) add_definitions(${NANOGUI_EXTRA_DEFS}) diff --git a/src/normals.cpp b/src/normals.cpp new file mode 100644 index 0000000..0620353 --- /dev/null +++ b/src/normals.cpp @@ -0,0 +1,30 @@ +#include +#include + +NORI_NAMESPACE_BEGIN + +class NormalIntegrator : public Integrator { +public: + NormalIntegrator(const PropertyList &props) { + /* No parameters this time */ + } + + Color3f Li(const Scene *scene, Sampler *sampler, const Ray3f &ray) const { + /* Find the surface that is visible in the requested direction */ + Intersection its; + if (!scene->rayIntersect(ray, its)) + return Color3f(0.0f); + + /* Return the component-wise absolute + value of the shading normal as a color */ + Normal3f n = its.shFrame.n.cwiseAbs(); + return Color3f(n.x(), n.y(), n.z()); + } + + std::string toString() const { + return "NormalIntegrator[]"; + } +}; + +NORI_REGISTER_CLASS(NormalIntegrator, "normals"); +NORI_NAMESPACE_END