26 Mart 2017 Pazar

Homework 3

The images below were generated by using the supplied input files bunny.xml, horse.xml, killeroo.xml, dragon.xml, 

External libraries used:
- tinyxml2 (tinyxml2.h, tinyxml2.cpp are provided in the homework files.)
- lodepng (lodepng.h, lodepng.cpp are provided in the homework files.) 
- Eigen (Can be obtained from http://eigen.tuxfamily.org/) 

Command to compile:
g++ -I /usr/include/eigen3/ -std=c++11 -O3 main.cpp RayTracer.cpp Vec3d.cpp Ray.cpp shape.cpp tinyxml2.cpp lodepng.cpp BVH.cpp -o RayTracer

Computer specs:
Intel Core i7-2630QM CPU @ 2.00 GHz, 6 GB RAM

Running the ray tracer:
./RayTracer command should be fed by the relative path of the input file, e. g.,
795_input_set_02/horse.xml

This week's task was to accelerate render time by implementing Bounding Volume Hierarchy (BVH). 


File name: bunny.xml
Triangle count: 4967
Render time w/o BVH and flat shading mode:
~53 seconds
Render time w/o BVH and smooth shading mode: ~56 seconds
Render time w/ BVH and flat shading mode: 0.586 seconds
Render time w/ BVH and smooth shading mode: 0.604 seconds




File name: horse.xml
Triangle count: 11216
Render time w/o BVH and flat shading mode:
~32 minutes
Render time w/o BVH and smooth shading mode: ~40 minutes
Render time w/ BVH and flat shading mode: 7.643 seconds
Render time w/ BVH and smooth shading mode: 7.834 seconds


File name: killeroo.xml
Triangle count: 92092
Render time w/o BVH and flat shading mode:
Infeasable to wait
Render time w/o BVH and smooth shading mode: Infeasable to wait
Render time w/ BVH and flat shading mode: 1.822 seconds
Render time w/ BVH and smooth shading mode: 1.951 seconds









File name: dragon.xml
Triangle count: 871414
Render time w/o BVH and flat shading mode:
Infeasable to wait
Render time w/o BVH and smooth shading mode: Infeasable to wait
Render time w/ BVH and flat shading mode: 6.047 seconds
Render time w/ BVH and smooth shading mode: 10.928 seconds









Comments and Notes:

1. Interestingly, rendering horse.xml takes more time than killeroo.xml despite its triangle count. One possibility of this is the BVH tree may be constructed in an unbalanced way for horse.xml. The other possibility is there is a floor under the horse which makes box at the root of the BVH tree so big that almost every ray intersects with this box which makes intersection query times greater.

2. Although BVH accelerates rendering time tremendously there are few optimization techniques that can be applied:
 - Advanced ray-box intersection methods can be used instead of naive methods.
 - Advanced ray-triangle intersection methods can be used instead of naive methods.
 - Code level optimizations.
These acceleration methods will be implemented in the following weeks.


20 Mart 2017 Pazartesi

Homework 2

The images below were generated by using the supplied input files bunny.xml, horse.xml, simple_transform.xml, spheres_transform.xml and horse_instanced.xml.

External libraries used:
- tinyxml2 (tinyxml2.h, tinyxml2.cpp are provided in the homework files.)
- lodepng (lodepng.h, lodepng.cpp are provided in the homework files.) 
- Eigen (Can be obtained from http://eigen.tuxfamily.org/) 

Command to compile:
g++ -I /usr/include/eigen3/ -std=c++11 -O3 main.cpp RayTracer.cpp Vec3d.cpp Ray.cpp shape.cpp tinyxml2.cpp lodepng.cpp -o RayTracer

Running the ray tracer:
./RayTracer command should be fed by the relative path of the input file, e. g.,
795_input_set_02/horse.xml


The image on the left is the output of bunny.xml file with smooth shading mode. It illustrates how bunny looks when it is rendered with smooth mode.

Generated around 56 seconds.

Please note that same image with flat mode was generated around 53 seconds.


The image on the left is the output of horse.xml file with smooth shading mode and when no transformation is applied. It illustrates how horse looks when it is rendered with smooth mode and without any transformation.

Generated around 39 minutes and 54 seconds.



The image on the left is the output of simple_transform.xml file. It just includes objects in the file simple.xml from the previous homework with some transformations applied.

Generated below 1 second.











The image on the left is the output of horse.xml file with flat shading mode and with the given transformations applied. The transformations are applied directly to the object rather than the ray. We can infer from the figure that translation and rotation works correctly. However, there may be a bug with the scaling because the horse in the given reference output was not as tall as in this image.

Generated around 32 minutes.



 The image on the left is the output of spheres_transform.xml file. This time, instead of transforming the objects, the ray is transformed to the object space. The image does not match with the image provided as reference output. From sphere at the left in the image, we can infer that translation operation works correctly. However, most probably there is a bug with the scaling and rotation matrixes while transforming the ray into the object space.

Generated below 1 second.





The image on the right creates three instances of the horse in the image two above. While instancing, copies of the objects with desired transformations are created rather than transforming the ray. The horses in the reference output provided are smooth while in the image on the left are flat. This is due to the fact that I tested instancing before implementing smoothing and I the image on the left was generated. However, generation of this scene took so much time that I could not rendered the scene again with the smooth mode.

Generated around 118 minutes.

12 Mart 2017 Pazar

Homework 1


The images below were generated by using the supplied input files simple.xml, simple_shading.xml, and bunny.xml, respectively.

External libraries used:
- tinyxml2 (tinyxml2.h, tinyxml2.cpp are provided in the homework files.)
- lodepng (lodepng.h, lodepng.cpp are provided in the homework files.)

Command to compile:
g++ -std=c++11 main.cpp RayTracer.cpp Vec3d.cpp Ray.cpp shape.cpp tinyxml2.cpp lodepng.cpp -o RayTracer

Running the ray tracer:

./RayTracer command should be fed by the relative path of the input file, e. g.,
795_input_set_01/simple.xml

The image on the left is the output of simple.xml file. It tests whether the intersection tests work correctly rather than the shading.
Generates image around 0.94 seconds.

The image on the left is the output of simple_shading.xml. It tests whether the simple shading models work correctly or not.
Generates image around 1.3 seconds.
















The image on the left is the output of bunny.xml. It tests whether complex mesh structures work correctly or not. Some triangles look black probably due to a bug in the triangle shading model which will be corrected in the next days.
Generates image around 2 minutes 35.5 seconds.