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)
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.
When finish implementing the interative path tracing algorithm and light scattering of diffuse material, I got something as below.
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!
The ideal specular material is easy to implement, I got something like this:
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:
By tweaking the SPECX, we can actually get different effect of the specular material:
First, I implement something according to the Snell's Law.
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.
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.
Putting everything together, we can get this!
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).
After getting all these to work, I start running some test on the stanford bunny with diffuse ans refractive material!
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.
I am actually testing the new method on top on last project, and I get the testing result as follows:
It proved our assumption that using shared memory can speed up the program.
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.