Skip to content

ziyezhou-Jerry/Project3-CUDA-Path-Tracer

 
 

Repository files navigation

CUDA Path Tracer

University of Pennsylvania, CIS 565: GPU Programming and Architecture, Project 3

  • Ziye Zhou
  • Tested on: Windows 8.1, i7-4910 @ 2.90GHz 32GB, GTX 880M 8192MB (Alienware)

Representive Image

alt tag

Progress

Casting Ray From Camera

In order to make sure that the ray casting from camera to the scene is right, I visualize the direction of the casting ray to debug this part.

alt tag

Getting the Basic to Work

When finish implementing the interative path tracing algorithm and light scattering of diffuse material, I got something as below.

alt tag

This is really wierd since everything seems to work fine except the back wall. Then I figure out that it may be caused by numerical error since we are given realy thin wall. Therefore, I tried to change the thickness of wall to a larrger number and the problem is fixed! alt tag

Specular Material

The ideal specular material is easy to implement, I got something like this: alt tag

While for the imperfect specular materials, they are simulated using a probability distribution instead computing the strength of a ray bounce based on angles. I used the Equations 7, 8, and 9 of GPU Gems 3 Chapter 20 to generate a random specular ray. I got something like this: alt tag

By tweaking the SPECX, we can actually get different effect of the specular material: alt tag

Glass (Refractive) Material

First, I implement something according to the Snell's Law. alt tag

As we can see from the image, we can get the concentration effect for free! Based on that, I also add the Fresnel Law to get more realistic refractive effect. alt tag

Compare these two images, we can see that Fresnel Law can provide us with the highlight on the glass material and also some different effect around the edge of the object.

Everything Together

Putting everything together, we can get this! alt tag

Arbitrary Mesh

In order to make the scene more interesting, I decided to put the .obj file into the scene. First, I edited my OBJ Loader from CIS 560 to work on the GPU. Then, I implemented my own ray triangle intersection test as a __host__ __device__ function. I also generate some debug image to test the correctness of the intersection function (test both intersect and the normal direction). alt tag

After getting all these to work, I start running some test on the stanford bunny with diffuse ans refractive material! alt tag alt tag

Since brute force intersection test can be the bottle neck when we are importing large mesh, I also implement the AABB(Axis Aligned Bounding Box) for each OBJ so that before testing the ray triangle intersection, I will do the fast Ray Box intersection first to avoid some unnecessary computation.

Stream Compation with Shared Memory

I am actually testing the new method on top on last project, and I get the testing result as follows: alt tag

It proved our assumption that using shared memory can speed up the program.

Conclusion and Future Work

By doing this project, I actually get a better understanding of Path Tracing Algorithm. What's more, since I have already implemented a CPU version of Path Tracer in CIS 560, implementing this time using CUDA on GPU give me the chance to compare CPU and GPU programming. Due to the limit of time, I haven't implement more advanced accelaration algorithm for the intersection check in this project, which means it is still far from real-time rendering. I am willing to implement algorithms like K-D tree to help this speed up later.

About

GPU-accelerated path tracer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CMake 54.6%
  • C++ 24.4%
  • Cuda 17.6%
  • C 3.1%
  • Makefile 0.3%