Skip to content

Commit

Permalink
Render images, README.
Browse files Browse the repository at this point in the history
  • Loading branch information
terrynsun committed Oct 7, 2015
1 parent 91f21c6 commit e87370d
Show file tree
Hide file tree
Showing 25 changed files with 506 additions and 83 deletions.
86 changes: 72 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Terry Sun; Arch Linux, Intel i5-4670, GTX 750

A CUDA-accelerated path tracer: a global-illumination renderer.

![](img/main-10000.png)

## Features

### Materials
Expand All @@ -17,8 +19,14 @@ The pathtracer supports the following material surfaces:
* specular/reflective (perfect and imperfect): light reflects perfectly off the
surface; or, light takes an imperfect reflected directly using the [Phong
BRDF][gpu-specular].
* refractive (using [Schlick's Approximation][wiki-schlick] to blend reflective
and refractive light bounces): glass, water
* refractive (using [Schlick's Approximation][wiki-schlick] of the Fresnel
effect to blend reflective and refractive light bounces).

![](img/specular-5000.png)
![](img/refract-5000.png)

*(Left: specular exponent 200; specular exponent 25)*
*(Right: indices of refraction 1.31 (water ice), 1.7 (impure glass))*

[gpu-specular]: http://http.developer.nvidia.com/GPUGems3/gpugems3_ch20.html
[wiki-schlick]: https://en.wikipedia.org/wiki/Schlick%27s_approximation
Expand All @@ -30,30 +38,81 @@ of rays shot from the camera. DOF is defined with a focal distance from the
camera, at which objects are perfectly in focus, and an aperture radius,
defining the amount of variance added to each ray.

![](img/nodof.png)
![](img/dof05.png)
![](img/dof03.png)
![](img/dof-none-5000.png)
![](img/dof04-5000.png)

*(no DOF; DOF with distance 5.5, aperture 0.4; 5000 iterations each)*

### Antialiasing

Camera rays are shot from the camera's position in the direction of a pixel.
Antialiasing jitters the target of the ray within a pixel.
Antialiasing jitters the target of the ray within a pixel. This is a brief
computation that happens once per pixel per iteration; it has little impact on
performance.

![](img/aa-none-5000.png)
![](img/aa-5000.png)

*(note antialiasing along cube, light, and wall corners)*

### Texture mapping

Textures can be read in to define diffuse colors for a material.

For spheres, polar coordinates *phi* and *theta* are used as the UV coordinates,
wrapping a texture across a sphere. For cubes, polar coordinates are calculated
relative to the cube face; each face of the cube has an identical copy of the
texture.

For both texture and normal mapping: add a small amount of complexity to the
intersection tesitng code in order to output UV coordinates. Most of the cost,
if any, would come from additional memory requirements (access into global
memory when reading the texture).

[TODO: picture]
![](img/uv1-5000.png)
![](img/uv2-5000.png)

### Normal mapping

Textures can be read in to define ray-bounce surface normals (superceding normal
vectors generated by the geometry intersection).

Combining the two above effects:

![](img/globe-texture-5000.png)
![](img/globe-normal-5000.png)
![](img/globe-both-5000.png)

*(normal map only; texture map only; texture and normal map)*

### Stream compaction.

Shared-memory work-efficient stream compaction.
This pathtracer uses `thrust::remove_if` to perform stream compaction on dead
rays.

[TODO: analysis]
I also implemented a [GPU-shared-memory, work-efficient stream compaction
algorithm][p2-shared-mem]. Unfortunately I couldn't integrate that into this
project -- I suspect there are memory errors when I translated the stream
compaction to handle pathtracing structs rather than integer values.

### Texture mapping
[p2-shared-mem]: https://github.com/terrynsun/CIS565-P2-Stream-Compaction

w. stream compaction
500 iterations, w. back wall: 61.30s
500 iterations, w/o. back wall: 61.76

[TODO: picture(s)]
w/o. stream compaction
500 iterations, w. back wall: 47.95
500 iterations, w/o. back wall: 47.84

### Bump mapping
With - without stream compaction
Open box:
Closed box:

[TODO: picture(s)]
Small light:
Large light:

[TODO: analysis]

## Run

Expand Down Expand Up @@ -104,7 +163,6 @@ MATERIAL (material ID) //material header
RGB (float r) (float g) (float b) //diffuse color
SPECX (float specx) //specular exponent
SPECRGB (float r) (float g) (float b) //specular color
REFR (bool refr) //refractivity flag, 0 for no, 1 for yes
REFRIOR (float ior) //index of refraction for Fresnel effects
EMITTANCE (float emittance) //the emittance of the material; >0 is a light source
TEXTURE (int textureid) //texture corresponding to diffuse coloring
Expand Down
Binary file added img/aa-5000.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/aa-none-5000.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/dof-none-5000.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 removed img/dof03.png
Binary file not shown.
Binary file added img/dof04-5000.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 removed img/dof05.png
Binary file not shown.
Binary file added img/globe-both-5000.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/globe-normal-5000.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/globe-texture-5000.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/main-10000.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 removed img/nodof.png
Binary file not shown.
Binary file added img/refract-5000.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/specular-5000.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/uv1-5000.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/uv2-5000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 100 additions & 0 deletions scenes/aa.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Camera
CAMERA
RES 100 100
FOVY 45
ITERATIONS 5000
DEPTH 8
FILE aa
DOF -1 -1
EYE 0 8 2.5
VIEW 0 0 -1
UP 0 1 0

// ---------------------- Materials ---------------------- \\

// Emissive material (light)
MATERIAL 0
RGB 1 1 1
EMITTANCE 2

// Diffuse white
MATERIAL 1
RGB .98 .98 .98

// Diffuse orange
MATERIAL 2
RGB 0.85 .5 .3

// Diffuse purple
MATERIAL 3
RGB 0.55 .55 .85

// Textured
MATERIAL 4
RGB .35 .75 .35

// ---------------------- Objects ---------------------- \\

// Ceiling light
OBJECT 0
cube
material 0
TRANS 0 10 0
ROTAT 0 0 0
SCALE 6 .3 6

// Floor
OBJECT 1
cube
material 1
TRANS 0 0 0
ROTAT 0 0 0
SCALE 10 0.1 10

// Ceiling
OBJECT 2
cube
material 1
TRANS 0 10 0
ROTAT 0 0 90
SCALE 0.1 10 10

// Back wall
OBJECT 3
cube
material 1
TRANS 0 5 -5
ROTAT 0 90 0
SCALE 0.1 10 10

// Front wall
OBJECT 4
cube
material 1
TRANS 0 5 5
ROTAT 0 90 0
SCALE 0.1 10 10

// Left wall
OBJECT 5
cube
material 2
TRANS -5 5 0
ROTAT 0 0 0
SCALE 0.1 10 10

// Right wall
OBJECT 6
cube
material 3
TRANS 5 5 0
ROTAT 0 0 0
SCALE 0.1 10 10

// White textured
OBJECT 7
cube
material 4
TRANS 0 6 -1.5
ROTAT 0 15 25
SCALE 3 3 3
64 changes: 43 additions & 21 deletions scenes/cornell.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Camera
CAMERA
RES 800 800
RES 350 350
FOVY 45
ITERATIONS 500
ITERATIONS 5000
DEPTH 8
FILE cornell
FILE specular
DOF -1 -1
EYE 0.0 5 4.5
VIEW 0 0 -1
Expand All @@ -21,29 +21,35 @@ EMITTANCE 3
MATERIAL 1
RGB .98 .98 .98

// Diffuse red
// Diffuse orange
MATERIAL 2
RGB .85 .35 .35
RGB 0.85 .5 .3

// Diffuse green
// Diffuse purple
MATERIAL 3
RGB .35 .85 .35
RGB 0.55 .55 .85

// Specular yellow
// Globe textured
MATERIAL 4
RGB 0.4 0.4 0
SPECEX 50
SPECRGB 1 1 1
RGB .85 .35 .35

// Refractive green
// Perfect specular
MATERIAL 5
RGB 0.0 0.8 0.8
REFR 1
REFRIOR 1.5
RGB .3 .3 .3
SPECRGB .8 .8 .8
SPECEX 0

// Diffuse orange
// Imperfect specular
MATERIAL 6
RGB .8 .8 0
RGB .3 .3 .3
SPECRGB .8 .8 .8
SPECEX 20

// Less imperfect specular
MATERIAL 7
RGB .3 .3 .3
SPECRGB .8 .8 .8
SPECEX 100

// ---------------------- Objects ---------------------- \\

Expand Down Expand Up @@ -103,18 +109,34 @@ TRANS 5 5 0
ROTAT 0 0 0
SCALE 0.1 10 10

// Specular Yellow
// Reddish
OBJECT 7
sphere
material 4
TRANS -2 6 -1
TRANS 0 2.5 -2.5
ROTAT 0 0 0
SCALE 3 3 3

// Glass sphere
// Imperfect specular
OBJECT 8
sphere
material 6
TRANS 0 2 -1.5
TRANS -3 4.5 -0.5
ROTAT 0 0 0
SCALE 3 3 3

// Imperfect specular
OBJECT 9
sphere
material 7
TRANS 3 4.5 -0.5
ROTAT 0 0 0
SCALE 3 3 3

// Perfect specular
OBJECT 10
sphere
material 5
TRANS 0 5.5 -3.5
ROTAT 0 0 0
SCALE 3 3 3
2 changes: 1 addition & 1 deletion scenes/dof.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FOVY 45
ITERATIONS 5000
DEPTH 8
FILE dof
DOF -1 -1
DOF 5.5 0.4
EYE 0.0 5 4.5
VIEW 0 0 -1
UP 0 1 0
Expand Down
Loading

0 comments on commit e87370d

Please sign in to comment.