Add normals implementation
This commit is contained in:
parent
b9e3b4c29b
commit
c5732d64ad
|
@ -24,4 +24,7 @@ rules.ninja
|
|||
*.dir
|
||||
*.opendb
|
||||
Debug
|
||||
x64
|
||||
x64
|
||||
|
||||
*.exr
|
||||
*.png
|
||||
|
|
|
@ -88,6 +88,7 @@ add_executable(nori
|
|||
src/microfacet.cpp
|
||||
src/mirror.cpp
|
||||
src/dielectric.cpp
|
||||
src/normals.cpp
|
||||
)
|
||||
|
||||
add_definitions(${NANOGUI_EXTRA_DEFS})
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue