COMPUTER GRAPHICS
Project 2

Team Raster

Our Concept and Scene

We set out to create a scene with a basic Pokemon fight and were lucky enough to find models for Mudkip, Charmander, Pikachu, and Mewtwo Pokemons. However, due to hardware limitations the Pokemon fight turned into a Pokemon get-together.

For the scene, we downloaded different Pokemon models from CGTrader and put them together in Blender. We then found a grass model to tie the scene together. There are a total of 4,839,711 primitives in the scene and it took around 2 hours hours to render the scene using BVH acceleration structure and multi-threading on 6 cores.. We have made use of Phong shading as well as Point light sources for this scene.

Low vs High Resolution

The following two images are renders of our scene in low resolution 480x480 and high resolution 1440x1440.

Lighting

We employed Ambient Light, Directional Light, Point Light to render the same scene settings with a variation of different light sources.

Materials

We employed Cosine, Matte, Phong and Reflective materials. The following are the results for each

Cosine

Matte

Phong

Reflective

Flat vs Smooth Shading

Here we have implemented flat and smooth shading. In flat shading, each triangle has a constant normal and so each of them is colored with one color, giving the bunny a flat appearance. Whereas, in smooth shading, the normal of each triangle is dependent on the normals of its neighboring triangles, giving it a smoother appearance. (The above image is of the Stanford bunny.)

Additional Renders

We also rendered these additional scenes to experiment with features like shadows, lights and materials.


Charmander

We have employed the Phong shading scheme with point lighting for this render. Model taken from CGTrader

Pokemon As Seen From Behind

Test render of our final scene.

Ominous Pikachu

Evil looking Pikachu.

Acceleration Structure

Bounding Volume Hierarchy (BVH)

We used Bounding Volume Hierarchy (BVH) to speed up the rendering process. The following tables compare the render times of our ray tracer with and without the BVH acceleration structure. Our code can be run without the acceleration strucutre by commenting out line 34 in the raytracer.cpp file.

    The times were recorded on a machine with the following specifications:

    • Processor: Intel Core i5-9300H CPU @ 2.40GHz
    • RAM: 8 GB
    • System Type: 64-bit Operating System
    • Number of Cores: 4

Primitives Time With BVH (s) Time Without BVH (s) Resolution Primitives Time With BVH (s) Time Without BVH (s) Resolution
10 0.409609 0.354006 480x480 10 6.601609 6.336886 1980x1980
100 0.705417 1.579724 480x480 100 10.286034 28.950214 1980x1980
1000 2.343886 12.726601 480x480 1000 40.361636 305.437283 1980x1980
10000 17.597176 132.230667 480x480 10000 306.015275 3600+ 1980x1980
100000 190.195648 1457.913041 480x480 100000 2400+ Way too long 1980x1980

Code Features

  1. BRDF

    We have used the Bi-Directional Reflectance Distribution Function(BRDF's) to compute how light is reflected off of an opaque surface.

  2. Ray Tracers

    We have used two kinds of tracers, a basic tracer that samples each pixel only once and additionally we've also implemented a whitted ray tracer that allows us to set a max depth for reflectance.

  3. Acceleration Structure

    We used Bounding Volume Hierarchy (BVH) to speed up the rendering process.

  4. Lighting

    We used Ambient Light, Directional Light, Point Light, to render the same scene settings with a variation of different light sources.

  5. Geometry

    We employed multiple classes such as Planes, Spheres, Triangles and Smooth Triangles.

  6. Materials

    We used Matte Material, Phong and Reflective Materials to generate our renders.

  7. Cameras

    We implemented parallel and perspective cameras for different views.

Bonus Features

  1. Ply Files

    We can load any triangle mesh ply file.

  2. Multi threading

    Since raytracing is an embarassingly parallel problem, we implemented multi-threading using OpenMP. This allowed us to speed up our rendering even more.

  3. Smooth Shading

    We can choose between smooth or flat shading when loading a triangle mesh.

  4. Shadows

    We have additionally implemented shadows for Point light sources.

Compile instructions

Our code can be run without the acceleration strucutre by commenting out line 34 in the raytracer.cpp file.

With multi threading:

g++ -w .\raytracer.cpp .\cameras\*.cpp .\geometry\*.cpp .\materials\*.cpp .\samplers\*.cpp .\utilities\*.cpp .\world\*.cpp .\tracers\*.cpp .\build\shadingBuild.cpp .\lights\*.cpp .\brdfs\*.cpp .\acceleration\*.cpp -fopenmp

Without multi threading:: Comment out lines 38 and 40 in raytracer.cpp. Then compile using the following:

g++ -w .\raytracer.cpp .\cameras\*.cpp .\geometry\*.cpp .\materials\*.cpp .\samplers\*.cpp .\utilities\*.cpp .\world\*.cpp .\tracers\*.cpp .\build\shadingBuild.cpp .\lights\*.cpp .\brdfs\*.cpp .\acceleration\*.cpp

Build Files

Following are the build files used for creating different images. These build files can be found under the build folder. You may replace shadingBuild.cpp in this compile code with any of the filenames below:

g++ -w .\raytracer.cpp .\cameras\*.cpp .\geometry\*.cpp .\materials\*.cpp .\samplers\*.cpp .\utilities\*.cpp .\world\*.cpp .\tracers\*.cpp .\lights\*.cpp .\brdfs\*.cpp .\acceleration\*.cpp .\build\shadingBuild.cpp

Team

The members of Team Raster are: Anand Kumar, Maheen Khan, Rida Zahid Khan and Salman Younus. We are Computer Science majors at Habib University, taking Computer Graphics (CS440) with Dr. Waqar Saleem.

Anand Kumar

Maheen Khan

Rida Khan

Salman Younus

Acknowledgements