####University of Pennsylvania ####CIS 565: GPU Programming and Architecture
##Project 3 - CUDA Path Tracer
- Xueyin Wan
- Tested on: Windows 7, Xeon(R) E5-1630 @ 3.70GHz 32GB, GTX 1070 8192MB (Moore 103 SigLab)
- Compiled with Visual Studio 2013 and CUDA 7.5
================================================================== ##My Path Tracer Features ###Core Features
- A shading kernel with BSDF evaluation:
- Ideal Diffuse surfaces
- Perfectly specular-reflective (mirrored) surfaces
- Path continuation/termination using Stream Compaction
- toggle between sorting path/intersection continuous by material type
- toggle between cache first bounce
###Extra Coolness
- Refraction (e.g. glass/water) [PBRT 8.2] with Frensel effects using Schlick's approximation(finally...)
Found great reference: http://graphics.stanford.edu/courses/cs148-10-summer/docs/2006--degreve--reflection_refraction.pdf - Physically-based depth-of-field
- Motion Blur
- More is coming!
================================================================== ###Result In Progress
####Fresnel Refraction Using Schlick's Approximation(http://graphics.stanford.edu/courses/cs148-10-summer/docs/2006--degreve--reflection_refraction.pdf)
####Diffuse, Perfect Specular Wall, Transmissive and Depth of Field
Left Wall
: Reflection = 1Left Blue Ball
: Refraction = 1Middle Purple Ball
: Refraction + Reflection = 1, No DiffuseRight Pink Ball
: Only Diffuse
Original | With DOF |
---|---|
####Motion Blur Motion Blur: The left sphere and middle cube is moving during the whole render process
####Depth of Field Comparison
Left Ball
: Refraction = 1Middle Cube
: Reflection = 0.4, Refraction = 0.6, Refraction + Reflection = 1, No Diffuse,Right Ball
: Reflection = 0.2, Refraction = 0.2, Diffuse = 0.6
Focal Length = 10.5 | Focal Length = 9 |
---|---|
####SEE WHERE I START FROM... ####BE CONFIDENT ABOUT YOUR HARD WORK!!! BE CONFIDENT ON THE WAY OF GPU!!! BE CONFIDENT WHEN FINDING A JOB!!!
Ideal Diffuse surfaces | Perfectly specular-reflective surfaces |
---|---|
================================================================== ###ON or OFF? SORT_BY_MATERIAL, CACHE_FIRST_BOUNCE, STREAM_COMPATION
STATUS | SORT_BY_MATERIAL | CACHE_FIRST_BOUNCE | STREAM_COMPATION | 5000 INTERATIONS TOTAL TIME (s) |
---|
| ON | OFF | OFF | 670.627
| OFF| ON | OFF | 100.689
| OFF| OFF | ON | 169.234
| OFF| OFF | OFF | 117.215
Above results is based on my cornellTestDOFLAB.txt. I used Siglab Machine to run all the results.
###How to implement these Toggle? In pathtrace.cu, using Macro definition to realize this :)
#define SORT_BY_MATERIAL 0
#define CACHE_FIRST_INTERSECTION 0
#define STREAM_COMPACTION 0
Thanks google groups!
For STREAM_COMPACTION
, I used thrust::partition()
method to calculate number of paths alive.
For CACHE_FIRST_INTERSECTION
, I made two helper variables:
bool cache_first_intersection
static ShadeableIntersection * dev_first_intersections
and use cudaMemcpy() method to copy the first batch of intersections into dev_first_intersection memory.
For SORT_BY_MATERIAL
, I made helper comparator MaterialComparator()
and used thrust::sort_by_key()
method to realize sorting by mateiral.
###What can we learn from the table above?
- SORT_BY_MATERIAL is the slowest one.. If there're a lot of materials in this code, I think that should be better.
- CACHE_FIRST_INTERSECTION : Totally went wrong when I opened DOF. But without DOF, result is good.
- STREAM_COMPACTION : Slower than all-OFF, I think maybe the ray's amount is huge, so the method takes unnecessary time. The method itself is good, yet sorting/compaction is slow (which is a pity :(.
From the pictures above, we could see ComputerIntersections
is the most time wasted(72.79%), since this function is used to calculate all the intersections, and as we noticed, the ray's amount is huge.
The second part is shadeFakeMaterial
, since we need to deal with each ray's color, remainging bounces information.