From 394a1ad43da092a5f58cbed1b6700ace1d94c0e8 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 9 May 2020 16:50:19 +0200 Subject: [PATCH] pathtracer: examples: cornell box w/o material light --- .../examples/cornell-box-no-emission.yaml | 30 ++++ .../examples/objs/cornell-box-no-emission.mtl | 88 +++++++++ .../examples/objs/cornell-box-no-emission.obj | 168 ++++++++++++++++++ pathtracer/src/render/bidirectional/path.rs | 9 +- 4 files changed, 289 insertions(+), 6 deletions(-) create mode 100644 pathtracer/examples/cornell-box-no-emission.yaml create mode 100644 pathtracer/examples/objs/cornell-box-no-emission.mtl create mode 100644 pathtracer/examples/objs/cornell-box-no-emission.obj diff --git a/pathtracer/examples/cornell-box-no-emission.yaml b/pathtracer/examples/cornell-box-no-emission.yaml new file mode 100644 index 0000000..a6e5a07 --- /dev/null +++ b/pathtracer/examples/cornell-box-no-emission.yaml @@ -0,0 +1,30 @@ +reflection_limit: 5 +shot_rays: 50 + +camera: + origin: [0.0, 1.0, 0.0] + forward: [ 0.0, 0.0, 1.0] + up: [0.0, 1.0, 0.0] + fov: 60.0 + distance_to_image: 1.0 + x: 1080 + y: 1080 + +lights: + ambients: + - color: {r: 0.1, g: 0.1, b: 0.1} + points: + - position: [0.0, 1.95, 3.2] + color: {r: 1.0, g: 1.0, b: 1.0} + +meshes: + # FIXME: make the path relative to the YAML in some way? + # Easiest solution would be to chdir to the YAML's directory + - obj_file: "pathtracer/examples/objs/cornell-box-no-emission.obj" + translation: [0.0, 0.0, 2.8] + rotation: [0, 180, 0] + +steps: + - 10 + - 25 + diff --git a/pathtracer/examples/objs/cornell-box-no-emission.mtl b/pathtracer/examples/objs/cornell-box-no-emission.mtl new file mode 100644 index 0000000..e801441 --- /dev/null +++ b/pathtracer/examples/objs/cornell-box-no-emission.mtl @@ -0,0 +1,88 @@ +# The original Cornell Box in OBJ format. +# Note that the real box is not a perfect cube, so +# the faces are imperfect in this data set. +# +# Created by Guedis Cardenas and Morgan McGuire at Williams College, 2011 +# Released into the Public Domain. +# +# http://graphics.cs.williams.edu/data +# http://www.graphics.cornell.edu/online/box/data.html +# + +newmtl leftWall + Ns 10.0000 + Ni 1.5000 + illum 2 + Ka 0.63 0.065 0.05 # Red + Kd 0.63 0.065 0.05 + Ks 0 0 0 + Ke 0 0 0 + + +newmtl rightWall + Ns 10.0000 + Ni 1.5000 + illum 2 + Ka 0.14 0.45 0.091 # Green + Kd 0.14 0.45 0.091 + Ks 0 0 0 + Ke 0 0 0 + + +newmtl floor + Ns 10.0000 + Ni 1.0000 + illum 2 + Ka 0.725 0.71 0.68 # White + Kd 0.725 0.71 0.68 + Ks 0 0 0 + Ke 0 0 0 + + +newmtl ceiling + Ns 10.0000 + Ni 1.0000 + illum 2 + Ka 0.725 0.71 0.68 # White + Kd 0.725 0.71 0.68 + Ks 0 0 0 + Ke 0 0 0 + + +newmtl backWall + Ns 10.0000 + Ni 1.0000 + illum 2 + Ka 0.725 0.71 0.68 # White + Kd 0.725 0.71 0.68 + Ks 0 0 0 + Ke 0 0 0 + + +newmtl shortBox + Ns 10.0000 + Ni 1.0000 + illum 2 + Ka 0.725 0.71 0.68 # White + Kd 0.725 0.71 0.68 + Ks 0 0 0 + Ke 0 0 0 + + +newmtl tallBox + Ns 10.0000 + Ni 1.0000 + illum 2 + Ka 0.725 0.71 0.68 # White + Kd 0.725 0.71 0.68 + Ks 0 0 0 + Ke 0 0 0 + +newmtl light + Ns 10.0000 + Ni 1.0000 + illum 2 + Ka 0.78 0.78 0.78 # White + Kd 0.78 0.78 0.78 + Ks 0 0 0 + Ke 0 0 0 diff --git a/pathtracer/examples/objs/cornell-box-no-emission.obj b/pathtracer/examples/objs/cornell-box-no-emission.obj new file mode 100644 index 0000000..2ee2137 --- /dev/null +++ b/pathtracer/examples/objs/cornell-box-no-emission.obj @@ -0,0 +1,168 @@ +# The original Cornell Box in OBJ format. +# Note that the real box is not a perfect cube, so +# the faces are imperfect in this data set. +# +# Created by Guedis Cardenas and Morgan McGuire at Williams College, 2011 +# Released into the Public Domain. +# +# http://graphics.cs.williams.edu/data +# http://www.graphics.cornell.edu/online/box/data.html +# + +mtllib cornell-box-no-emission.mtl + +## Object floor +v -1.01 0.00 0.99 +v 1.00 0.00 0.99 +v 1.00 0.00 -1.04 +v -0.99 0.00 -1.04 + +g floor +usemtl floor +f -4 -3 -2 -1 + +## Object ceiling +v -1.02 1.99 0.99 +v -1.02 1.99 -1.04 +v 1.00 1.99 -1.04 +v 1.00 1.99 0.99 + +g ceiling +usemtl ceiling +f -4 -3 -2 -1 + +## Object backwall +v -0.99 0.00 -1.04 +v 1.00 0.00 -1.04 +v 1.00 1.99 -1.04 +v -1.02 1.99 -1.04 + +g backWall +usemtl backWall +f -4 -3 -2 -1 + +## Object rightwall +v 1.00 0.00 -1.04 +v 1.00 0.00 0.99 +v 1.00 1.99 0.99 +v 1.00 1.99 -1.04 + +g rightWall +usemtl rightWall +f -4 -3 -2 -1 + +## Object leftWall +v -1.01 0.00 0.99 +v -0.99 0.00 -1.04 +v -1.02 1.99 -1.04 +v -1.02 1.99 0.99 + +g leftWall +usemtl leftWall +f -4 -3 -2 -1 + +## Object shortBox +usemtl shortBox + +# Top Face +v 0.53 0.60 0.75 +v 0.70 0.60 0.17 +v 0.13 0.60 0.00 +v -0.05 0.60 0.57 +f -4 -3 -2 -1 + +# Left Face +v -0.05 0.00 0.57 +v -0.05 0.60 0.57 +v 0.13 0.60 0.00 +v 0.13 0.00 0.00 +f -4 -3 -2 -1 + +# Front Face +v 0.53 0.00 0.75 +v 0.53 0.60 0.75 +v -0.05 0.60 0.57 +v -0.05 0.00 0.57 +f -4 -3 -2 -1 + +# Right Face +v 0.70 0.00 0.17 +v 0.70 0.60 0.17 +v 0.53 0.60 0.75 +v 0.53 0.00 0.75 +f -4 -3 -2 -1 + +# Back Face +v 0.13 0.00 0.00 +v 0.13 0.60 0.00 +v 0.70 0.60 0.17 +v 0.70 0.00 0.17 +f -4 -3 -2 -1 + +# Bottom Face +v 0.53 0.00 0.75 +v 0.70 0.00 0.17 +v 0.13 0.00 0.00 +v -0.05 0.00 0.57 +f -12 -11 -10 -9 + +g shortBox +usemtl shortBox + +## Object tallBox +usemtl tallBox + +# Top Face +v -0.53 1.20 0.09 +v 0.04 1.20 -0.09 +v -0.14 1.20 -0.67 +v -0.71 1.20 -0.49 +f -4 -3 -2 -1 + +# Left Face +v -0.53 0.00 0.09 +v -0.53 1.20 0.09 +v -0.71 1.20 -0.49 +v -0.71 0.00 -0.49 +f -4 -3 -2 -1 + +# Back Face +v -0.71 0.00 -0.49 +v -0.71 1.20 -0.49 +v -0.14 1.20 -0.67 +v -0.14 0.00 -0.67 +f -4 -3 -2 -1 + +# Right Face +v -0.14 0.00 -0.67 +v -0.14 1.20 -0.67 +v 0.04 1.20 -0.09 +v 0.04 0.00 -0.09 +f -4 -3 -2 -1 + +# Front Face +v 0.04 0.00 -0.09 +v 0.04 1.20 -0.09 +v -0.53 1.20 0.09 +v -0.53 0.00 0.09 +f -4 -3 -2 -1 + +# Bottom Face +v -0.53 0.00 0.09 +v 0.04 0.00 -0.09 +v -0.14 0.00 -0.67 +v -0.71 0.00 -0.49 +f -8 -7 -6 -5 + +g tallBox +usemtl tallBox + +## Object light +v -0.24 1.98 0.16 +v -0.24 1.98 -0.22 +v 0.23 1.98 -0.22 +v 0.23 1.98 0.16 + +g light +usemtl light +f -4 -3 -2 -1 diff --git a/pathtracer/src/render/bidirectional/path.rs b/pathtracer/src/render/bidirectional/path.rs index 0bca927..e9f909e 100644 --- a/pathtracer/src/render/bidirectional/path.rs +++ b/pathtracer/src/render/bidirectional/path.rs @@ -4,8 +4,7 @@ use nalgebra::Unit; pub struct PathPoint { pub point: Point, - pub incident: Unit, - pub normal: Unit, + pub pdf: f32, pub properties: LightProperties, } @@ -13,14 +12,12 @@ impl PathPoint { #[allow(unused)] pub fn new( point: Point, - incident: Unit, - normal: Unit, + pdf: 32, properties: LightProperties, ) -> Self { PathPoint { point, - incident, - normal, + pdf, properties, } }