Add normals implementation

This commit is contained in:
Pavle Portic 2024-03-05 22:41:00 +01:00
parent b9e3b4c29b
commit c5732d64ad
Signed by: TheEdgeOfRage
GPG Key ID: 66AD4BA646FBC0D2
3 changed files with 35 additions and 1 deletions

5
.gitignore vendored
View File

@ -24,4 +24,7 @@ rules.ninja
*.dir
*.opendb
Debug
x64
x64
*.exr
*.png

View File

@ -88,6 +88,7 @@ add_executable(nori
src/microfacet.cpp
src/mirror.cpp
src/dielectric.cpp
src/normals.cpp
)
add_definitions(${NANOGUI_EXTRA_DEFS})

30
src/normals.cpp Normal file
View File

@ -0,0 +1,30 @@
#include <nori/integrator.h>
#include <nori/scene.h>
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