Homework 1: First blood
In this assignment, we are expected to implement a basic ray tracer. The ray tracer is supposed to satisfy some properties, such as:
- Parsing scene files which are XML format
- Being able to render images of different cameras of the scene
- Intersecting with spheres, triangles, and meshes.
- Finding the nearest intersected object for the related pixel.
- Deciding if the point is in shadow
- Computing ambient, diffuse, specular shadings of the contact point
- If the surface has mirror reflectance, being able to compute reflected color in a recursive way
- lodepng - a PNG encoder and decoder in C and C++.
- tinyxml2 - TinyXML-2 is a simple, small, efficient, C++ XML parser that can be easily integrated into other programs.
- https://stackoverflow.com/a/22064449 - A modified version of this answer, for profiling and printing the duration of the each rendering.
I didn't use any acceleration structures and barely did optimizations. I belie that low level optimizations should be done after the introducing algorithmic acceleration with the structures. I just tried to use a Vector3 implementation which uses SIMD instructions, but it didn't change anything. I believe that -O3 optimization level just achieves the same optimization for the normal implementation of the Vector3. I just rendered my image by sharing the rows of the image to the threads in an alternating way.
Scenes provided:
- bunny.xml
rendering on #8 thread(s)
bunny.png(512x512) is saved in: 6 seconds 717 milliseconds 342 microseconds
- cornellbox.xml
rendering on #8 thread(s)
cornellbox.png(800x800) is saved in: 81 milliseconds 689 microseconds
To run the code on Linux/Mac OS:
$ make
$ ./raytracer [scene_file]
Probably, it can also be compiled at Windows. In the next assignments I may use Cmake for generating cross platform projects/builds.
https://github.com/bilalyaylak/ceng795 (private for now, link may change in the future)
Yorumlar
Yorum Gönder