Skip to content

final submission for Project 2 #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Binary file added 10020311.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 10021224.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 10021245.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 10021259.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 10021534.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 10021636.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 10021740.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 10022047.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 10022141.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 10022256.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMG_1929.MOV
Binary file not shown.
174 changes: 78 additions & 96 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,143 +5,125 @@ Fall 2013
-------------------------------------------------------------------------------
Due Wednesday, 10/02/13
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
NOTE:
Qiong Wang
-------------------------------------------------------------------------------
This project requires an NVIDIA graphics card with CUDA capability! Any card after the Geforce 8xxx series will work. If you do not have an NVIDIA graphics card in the machine you are working on, feel free to use any machine in the SIG Lab or in Moore100 labs. All machines in the SIG Lab and Moore100 are equipped with CUDA capable NVIDIA graphics cards. If this too proves to be a problem, please contact Patrick or Liam as soon as possible.


-------------------------------------------------------------------------------
INTRODUCTION:
INTRODUCTION
-------------------------------------------------------------------------------
In this project, you will extend your raytracer from Project 1 into a full CUDA based global illumination pathtracer.
This is a fast GPU path tracer initialized by a CUDA ray tracer with ray parallelization. It is one project of CIS 565 GPU Programming course at University of Pennsylvania.

For this project, you may either choose to continue working off of your codebase from Project 1, or you may choose to use the included basecode in this repository. The basecode for Project 2 is the same as the basecode for Project 1, but with some missing components you will need filled in, such as the intersection testing and camera raycasting methods.
The basic algorithm of the path tracing of this project can be summarized as:

How you choose to extend your raytracer into a pathtracer is a fairly open-ended problem; the supplied basecode is meant to serve as one possible set of guidelines for doing so, but you may choose any approach you want in your actual implementation, including completely scrapping the provided basecode in favor of your own from-scratch solution.
1. Build a pool of rays that need to be tested;
2. Construct an image that each color can be accumulated;
3. Launch a kernel to trace one bounce of a ray;
4. Add any new rays to the pool after bounce and check whether the ray hits the light source or not;
5. Remove terminated rays from the pool;
6. Repeat the third step until no ray left in the pool.

-------------------------------------------------------------------------------
CONTENTS:
-------------------------------------------------------------------------------
The Project2 root directory contains the following subdirectories:

* src/ contains the source code for the project. Both the Windows Visual Studio solution and the OSX makefile reference this folder for all source; the base source code compiles on OSX and Windows without modification.
* scenes/ contains an example scene description file.
* renders/ contains two example renders: the raytraced render from Project 1 (GI_no.bmp), and the same scene rendered with global illumination (GI_yes.bmp).
* PROJ1_WIN/ contains a Windows Visual Studio 2010 project and all dependencies needed for building and running on Windows 7.
* PROJ1_OSX/ contains a OSX makefile, run script, and all dependencies needed for building and running on Mac OSX 10.8.
* PROJ1_NIX/ contains a Linux makefile for building and running on Ubuntu
12.04 LTS. Note that you will need to set the following environment
variables:

- PATH=$PATH:/usr/local/cuda-5.5/bin
- LD_LIBRARY_PATH=/usr/local/cuda-5.5/lib64:/lib
Since the number of the ray in the ray pool decreases we need fewer blocks per grid when launching the kernel. Hence, we can have a quite fast execution speed for the path tracer.

The projects build and run exactly the same way as in Project0 and Project1.
Note: Please run the 565Raytracer.sln file rather to run the 565Pathtracer.sln one, you can directly copy the 565Raytracer file from the Project 1 repo. Thank you :)

-------------------------------------------------------------------------------
REQUIREMENTS:
FEATURES IMPLEMENTED
-------------------------------------------------------------------------------
In this project, you are given code for:

* All of the basecode from Project 1, plus:
* Intersection testing code for spheres and cubes
* Code for raycasting from the camera

You will need to implement the following features. A number of these required features you may have already implemented in Project 1. If you have, you are ahead of the curve and have less work to do!
Basic features:

* Full global illumination (including soft shadows, color bleeding, etc.) by pathtracing rays through the scene.
* Properly accumulating emittance and colors to generate a final image
* Supersampled antialiasing
* Parallelization by ray instead of by pixel via string compaction
* Perfect specular reflection

You are also required to implement at least two of the following features. Some of these features you may have already implemented in Project 1. If you have, you may NOT resubmit those features and instead must pick two new ones to implement.
Optional features:

* Additional BRDF models, such as Cook-Torrance, Ward, etc. Each BRDF model may count as a separate feature.
* Texture mapping
* Bump mapping
* Translational motion blur
* Fresnel-based Refraction, i.e. glass
* OBJ Mesh loading and rendering without KD-Tree
* Interactive camera
* Integrate an existing stackless KD-Tree library, such as CUKD (https://github.com/unvirtual/cukd)
* Depth of field
* Fresnel-based Refraction, i.e. glass (Still tuning)

Alternatively, implementing just one of the following features can satisfy the "pick two" feature requirement, since these are correspondingly more difficult problems:

* Physically based subsurface scattering and transmission
* Implement and integrate your own stackless KD-Tree from scratch.
* Displacement mapping
* Deformational motion blur

As yet another alternative, if you have a feature or features you really want to implement that are not on this list, let us know, and we'll probably say yes!

-------------------------------------------------------------------------------
NOTES ON GLM:
SCREENSHOTS OF THE FEATURES IMPLEMENTED
-------------------------------------------------------------------------------
This project uses GLM, the GL Math library, for linear algebra. You need to know two important points on how GLM is used in this project:
* Global illumination

* In this project, indices in GLM vectors (such as vec3, vec4), are accessed via swizzling. So, instead of v[0], v.x is used, and instead of v[1], v.y is used, and so on and so forth.
* GLM Matrix operations work fine on NVIDIA Fermi cards and later, but pre-Fermi cards do not play nice with GLM matrices. As such, in this project, GLM matrices are replaced with a custom matrix struct, called a cudaMat4, found in cudaMat4.h. A custom function for multiplying glm::vec4s and cudaMat4s is provided as multiplyMV() in intersections.h.
![ScreenShot](https://raw.github.com/GabriellaQiong/Project2-Pathtracer/master/10021534.PNG)

-------------------------------------------------------------------------------
README
-------------------------------------------------------------------------------
All students must replace or augment the contents of this Readme.md in a clear
manner with the following:
* Properly accumulating emittance and colors to generate a final image

* A brief description of the project and the specific features you implemented.
* At least one screenshot of your project running.
* A 30 second or longer video of your project running. To create the video you
can use http://www.microsoft.com/expression/products/Encoder4_Overview.aspx
* A performance evaluation (described in detail below).
![ScreenShot](https://raw.github.com/GabriellaQiong/Project2-Pathtracer/master/10021636.PNG)

-------------------------------------------------------------------------------
PERFORMANCE EVALUATION
-------------------------------------------------------------------------------
The performance evaluation is where you will investigate how to make your CUDA
programs more efficient using the skills you've learned in class. You must have
performed at least one experiment on your code to investigate the positive or
negative effects on performance.
* Antialiasing (Stochastic method)

One such experiment would be to investigate the performance increase involved
with adding a spatial data-structure to your scene data.
![ScreenShot](https://raw.github.com/GabriellaQiong/Project2-Pathtracer/master/anti-aliasing.PNG)

Another idea could be looking at the change in timing between various block
sizes.
* Perfect specular reflection

![ScreenShot](https://raw.github.com/GabriellaQiong/Project2-Pathtracer/master/10021740.PNG)

A good metric to track would be number of rays per second, or frames per
second, or number of objects displayable at 60fps.
* Translational motion blur

We encourage you to get creative with your tweaks. Consider places in your code
that could be considered bottlenecks and try to improve them.
![ScreenShot](https://raw.github.com/GabriellaQiong/Project2-Pathtracer/master/10022256.PNG)

* Depth of field

With small radius for the circle of confusion

![ScreenShot](https://raw.github.com/GabriellaQiong/Project2-Pathtracer/master/10022047.PNG)

With big radius for the circle of confusion

![ScreenShot](https://raw.github.com/GabriellaQiong/Project2-Pathtracer/master/10022141.PNG)

Each student should provide no more than a one page summary of their
optimizations along with tables and or graphs to visually explain any
performance differences.

-------------------------------------------------------------------------------
THIRD PARTY CODE POLICY
VIDEOS OF IMPLEMENTATION
-------------------------------------------------------------------------------
* Use of any third-party code must be approved by asking on the Google group. If it is approved, all students are welcome to use it. Generally, we approve use of third-party code that is not a core part of the project. For example, for the ray tracer, we would approve using a third-party library for loading models, but would not approve copying and pasting a CUDA function for doing refraction.
* Third-party code must be credited in README.md.
* Using third-party code without its approval, including using another student's code, is an academic integrity violation, and will result in you receiving an F for the semester.

This is the video of the rendering process of the path tracer.

[![ScreenShot](https://raw.github.com/GabriellaQiong/Project2-Pathtracer/master/videoScreenShot.PNG)](http://www.youtube.com/watch?v=GcbRUaLgz5A)

The youtube link is here if you cannot open the video in the markdown file: http://www.youtube.com/watch?v=GcbRUaLgz5A


-------------------------------------------------------------------------------
SELF-GRADING
PERFORMANCE EVALUATION
-------------------------------------------------------------------------------
* On the submission date, email your grade, on a scale of 0 to 100, to Liam, [email protected], with a one paragraph explanation. Be concise and realistic. Recall that we reserve 30 points as a sanity check to adjust your grade. Your actual grade will be (0.7 * your grade) + (0.3 * our grade). We hope to only use this in extreme cases when your grade does not realistically reflect your work - it is either too high or too low. In most cases, we plan to give you the exact grade you suggest.
* Projects are not weighted evenly, e.g., Project 0 doesn't count as much as the path tracer. We will determine the weighting at the end of the semester based on the size of each project.
Here is the table for the performance evaluation when changing the size of tile and with stream compaction or not.

| tileSize | with compaction | time for running 10 iteration | approximate fps |
|:---------:|:-----------------:|:---------------------------------------:|:-----------------:|
| 8 | yes | 0 : 22.72 | 0.440 |
| 10 | yes | 0 : 25.97 | 0.385 |
| 8 | no | 0 : 23.39 | 0.428 |
| 10 | no | 0 : 27.47 | 0.364 |

We can easily find that when the tile size become larger the fps decrease a little somehow. The fps with stream compaction is higher than that without stream compaction.

-------------------------------------------------------------------------------
SUBMISSION
REFERENCES
-------------------------------------------------------------------------------
As with the previous project, you should fork this project and work inside of your fork. Upon completion, commit your finished project back to your fork, and make a pull request to the master repository.
You should include a README.md file in the root directory detailing the following
* Snell's law: http://en.wikipedia.org/wiki/Snell%27s_law

* Internal Reflection: http://en.wikipedia.org/wiki/Total_internal_reflection

* Fresnel Equation: http://en.wikipedia.org/wiki/Fresnel_equations

* Russian Roulette rule from Peter and Karl: https://docs.google.com/file/d/0B72qrSEH6CGfbFV0bGxmLVJiUlU/edit

* General Phong Specular Model: http://en.wikipedia.org/wiki/Phong_reflection_model

* Depth of Field: http://http.developer.nvidia.com/GPUGems/gpugems_ch23.html

* A brief description of the project and specific features you implemented
* At least one screenshot of your project running, and at least one screenshot of the final rendered output of your pathtracer
* Instructions for building and running your project if they differ from the base code
* A link to your blog post detailing the project
* A list of all third-party code used
* Stochastic Sampling: http://pages.cpsc.ucalgary.ca/~mario/courses/591-691-W06/PR/3-ray-tracing/3-advanced/readings/Cook_Stochastic_Sampling_TOG86.pdf

* Usage of thrust in stream compaction: http://stackoverflow.com/questions/12201446/converting-thrustiterators-to-and-from-raw-pointers/12236270#12236270

-------------------------------------------------------------------------------
ACKNOWLEDGEMENT
-------------------------------------------------------------------------------
Thanks a lot to Patrick and Liam for the preparation of this project. And special thanks to Liam who helped us debugging so late till 4:30 am in the morning! Thank you all :)
Binary file added anti-aliasing.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading