*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit 0e326d25 authored by android172's avatar android172
Browse files

Added benchmark render to tests

parent 92d71f8d
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ RENDER_SCENES = [
["veach_room_ao_uniform.xml", 30, "", ""],
["veach_room_path_tracer_mesh.xml", 50, "veach_room_path_tracer_parallelogram.png", ""],
["veach_room_path_tracer_parallelogram.xml", 50, "veach_room_path_tracer_mesh.png", "to_veach_room_path_tracer_mesh.xml"]
["sponza_path_tracer_benchmark.xml", 300, "", ""],
]
TEST_SCENES = [
......
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 49a8568..3621d0c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,6 +41,7 @@ include_directories(
# The following lines build the main executable. If you add a source
# code file to Nori, be sure to include it in this list.
add_executable(nori
+ src/integrator_benchmark.cpp
# Header files
include/nori/bbox.h
diff --git a/src/integrator_benchmark.cpp b/src/integrator_benchmark.cpp
new file mode 100644
index 0000000..9785389
--- /dev/null
+++ b/src/integrator_benchmark.cpp
@@ -0,0 +1,94 @@
+#include <nori/integrator.h>
+#include <nori/scene.h>
+#include <nori/bsdf.h>
+#include <nori/sampler.h>
+
+NORI_NAMESPACE_BEGIN
+
+namespace {
+ Point2f squareToUniformDisk(const Point2f& sample) {
+ float r = std::sqrt(sample.y());
+ float sinPhi, cosPhi;
+ sincosf(2.0f * M_PI * sample.x(), &sinPhi, &cosPhi);
+
+ return Point2f(cosPhi * r, sinPhi * r);
+ }
+
+ Vector3f squareToCosineHemisphere(const Point2f& sample) {
+ Point2f p = squareToUniformDisk(sample);
+ float z = std::sqrt(std::max((float)0,
+ 1.0f - p.x() * p.x() - p.y() * p.y()));
+
+ return Vector3f(p.x(), p.y(), z);
+ }
+}
+
+class BenchmarkIntegrator : public Integrator {
+public:
+ constexpr static unsigned int MAX_DEPTH = 3;
+ BenchmarkIntegrator(const PropertyList& props) {
+ /* No parameters this time */
+ }
+
+ Color3f Li(const Scene* scene, Sampler* sampler, const Ray3f& _ray) const {
+
+// Intersection its;
+// auto r = ray;
+// if (!scene->rayIntersect(r, its))
+// return Color3f(1.0f);
+// static auto halfVector = Normal3f(0.5);
+// Normal3f n = (its.shFrame.n / 2.0) + halfVector;
+// Color3f bsdfWeight{ n.x(), n.y(), n.z() };
+// Color3f value(1.0f);
+
+// for (unsigned int d = 1; d <= MAX_DEPTH; d++) {
+// Vector3f local_out = squareToCosineHemisphere(sampler->next2D());
+// r = Ray3f(its.p + Epsilon * its.shFrame.n, its.shFrame.toWorld(local_out));
+
+// if (!scene->rayIntersect(r, its))
+// break;
+
+// value *= bsdfWeight;
+// }
+
+// return value;
+
+ Color3f result(0.0f), throughput(1.0f);
+ Intersection its;
+ int depth = 0;
+ Ray3f ray(_ray);
+
+ while (true) {
+ if (!scene->rayIntersect(ray, its)) {
+ result += throughput * Color3f(1);
+ break;
+ }
+
+ static auto halfVector = Normal3f(0.5);
+ Normal3f n = (its.shFrame.n / 2.0) + halfVector;
+ Color3f bsdfWeight{ n.x(), n.y(), n.z() };
+
+ throughput *= bsdfWeight;
+
+ Vector3f local_out = squareToCosineHemisphere(sampler->next2D());
+ ray = Ray3f(its.p + Epsilon * its.shFrame.n, its.shFrame.toWorld(local_out));
+
+ if (++depth > 3) {
+ float q = 0.9f;
+ if (sampler->next1D() >= q)
+ break;
+ throughput /= q;
+ }
+ }
+
+
+ return result;
+ }
+
+ std::string toString() const {
+ return "BenchmarkIntegrator[]";
+ }
+};
+
+NORI_REGISTER_CLASS(BenchmarkIntegrator, "benchmark");
+NORI_NAMESPACE_END
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment