Explore library potentialities
Here is a presentation of the program usage showing some examples to explore the potentialities of this raytracing library.
The scene files used to render these images are in the examples/render
directory, so you can try yourself!
Note: all the following images are rendered with antialiasing to sample each pixel properly (9 samples per pixel).
Demo image
Scene filename:
demo.txt
Here are gathered all the main functionalities of the library, in particular regarding path tracer. Note how it can render light interaction so naturally with total reflective, diffusive and emitting surfaces on the different shapes (spheres, boxes and planes).
This image was generated running
./parallelize-image.sh
with default parameters except for the 9samples
per pixel. We suggest to use the script to speed up the execution of the pathtracer rendering.
Here is a comparison with the other two tracers (flat and pointlight tracer) to better appreciate the advantages of using the pathtracer:
The last image is an edited version for the pointlight renderer because of its inability to represent reflective surfaces.
Scene filename:
demo_pointlight.txt
This image is so representative of the pontentials of the code… now let’s start exploring a bit more! 🤹🏻♀️
Sunset
Scene filename:
sunset.txt
Here you can see how a pointlight tracer is able to wonderfully render a situation where the light source is very intense and point-like (or far away, as the sun approaching the horizon…). Look how it can render the romantic long shadows of sunsets!
You can appreciate this tracer looking at the same scene rendered with the flat and path tracer:
Chess player
Scene filename:
chess.txt
This image simulates a chess game situation. It was an excuse to overuse the checkered pattern (not use in the demo image) and to make the antialiasing property evident (9 samples per pixel were here extracted on the right image). The pointlight renderer is perfect to simulate the intense atmosphere of this game, as well as to better show the antialiasing.
Look at this animation to better appreciate the differences!
Advise: tone down the image setting the luminosity factor
--a_r 0.6
in the command line if you want to reproduce this image yourself.
Fireflies
Scene filename:
fireflies.txt
The onoff renderer is usually used for debugging purposes when starting writing down the code, but you know what? I’m seeing fireflies dancing in a dark night!
Solar system
Scene filename:
solar_system.txt
Someone may think that the flat renderer is a second-class renderer, but it can be used for simple images with dark background and has the great advantage of being extremely quick… Look how it renders the solar system!
Being extremely quick it takes little time to generate this wonderful animation!
Advise: tone down the image setting the luminosity factor
--a_r 0.2
in the command line if you want to reproduce this image yourself.
Here an example rendered with the poinlight tracer:
Cornell box
Scene filename:
cornell_box.txt
The one and only cornell box! It is used in photorealistic rendering to test the accuracy of the code.
This cornell box was made by setting
--n_rays
4--depth
3--samples
25--width
400--height
400--a_r
0.55.
As you can notice the pathtracer algorithm has hard times in rendering multiple diffusive surfaces, but it’s a good starting point! You can appreciate the red/green faces of the boxes because of the light interaction with the walls, as well as the realistic shadows projected by the boxes and in the room corners.
👉🏽 Suggestion: thanks to the stratified sampling implementation increasing samples
rather than n_rays
reduces the grainy effect more efficiently.
Parallelize Cornell box execution
Shell script:
cornell_box.sh
Since the runtime increases as increasing the parameters value, a script cornell_box.sh
(in examples/render
) has been written to run the executable in parallel:
Usage: ./cornell_box.sh NUM_OF_CORES <n_rays> <depth> <samples> <width> <height> <a-factor>
You just need to set the NUM_OF_CORES
, while the other parameters are optional. Default values are set to render quickly an approximate 200x200 image
of the cornell box. You are welcome to set your own values!
Default values:
n_rays
2depth
2samples
16width
200height
200a-factor
0.6
The output files will be named to track the parameters setting (ex: cb_n4_d3_s25_w400_h400_a0.6.png
)
Voilà! You can see this cornell box example as an invitation to contribute at this library❣️