Ray Tracer - Part 1
Hello world! I’ll be sharing my experiences during the development of a Ray Tracer for the graduate-level course CENG795 Advanced Ray Tracing at Middle East Technical University.
I am using a Fedora system with i7-6700HQ processor and 16 GB (1600MHZ) of RAM as my development environment. I’m fond of using up-to-date software and tools. I’ll be using latest stable gcc version (8.3.1, for now) with the C++17 standard.
Implementation
For the first part, my goal is to create a basic ray tracer with:
- perspective camera model
- several shading models: diffuse, ambient, specular, mirror and dielectrics (transparency)
- hard shadows
For the requirements of the course, we need to read objects and scene details from XML files. In order to read and parse XML, I’ve used TinyXML2 library.
Spheres and triangles are the primitive object types that I’ve implemented first. Due to the simplicity of implementation, spheres are the most convenient objects to try first. Especially when testing the camera calculations and shading, spheres are very convenient for trying and catching the errors at early stages.
The most time consuming part for me was finding simple errors such as:
- Calculation errors: This can be very troublesome. Calculating directions, writing intersection equations are really prone to errors. Debugging this kind of errors cost me several hours.
- Floating point precision errors: This is kind of an enjoyable error for me! Seeing the actual results of floating point errors are really fascinating. They generally create some black dots at the edges of the objects. Using an appropriate epsilon value for floating point comparions is needed to fix.
I’ve used multi-threading to speed up my render times. Specifically, I’ve used std::thread from C++ standard library. More optimizations will be done in the upcoming weeks.
Future work
Acceleration structures, distribution ray tracing and more!