overview.md 5.87 KB
Newer Older
Hui Wang's avatar
Hui Wang committed
1
2
[[Home]](/docs/index.md)  [[User Guide]](/docs/guide/guide.md) [[Mesh Edit]](/docs/meshedit/overview.md) [[Path Tracer]](/docs/pathtracer/overview.md) [[Animation]](/docs/animation/overview.md)

yhesper's avatar
yhesper committed
3
4
5
6
---

# PathTracer Overview

TheNumbat's avatar
TheNumbat committed
7
PathTracer is (as the name suggests) a simple path tracer that can render scenes with global illumination. The first part of the assignment will focus on providing an efficient implementation of **ray-scene geometry queries**. In the second half of the assignment you will **add the ability to simulate how light bounces around the scene**, which will allow your renderer to synthesize much higher-quality images. Much like in MeshEdit, input scenes are defined in COLLADA files, so you can create your own scenes to render using Scotty3D or other free software like [Blender](https://www.blender.org/).
yhesper's avatar
yhesper committed
8

Hui Wang's avatar
Hui Wang committed
9
<center><img src="figures/raytracing_diagram.png" style="height:240px"></center>
TheNumbat's avatar
TheNumbat committed
10
11
12
13

Implementing the functionality of PathTracer is split into 7 tasks:
<center><img src="images/pathtracing_flowchart.png"></center>

Hui Wang's avatar
Hui Wang committed
14
15
16
17
18
19
20
21
22
23
24
25

- (Task 1) [Camera Rays](/docs/pathtracer/camera_rays.md)
- (Task 2) [Intersections](/docs/pathtracer/intersecting_objects.md)
    - [Ray Triangle Intersection](/docs/pathtracer/ray_triangle_intersection.md)
    - [Ray Sphere Intersection](/docs/pathtracer/ray_sphere_intersection.md)
- (Task 3) [BVH](/docs/pathtracer/bounding_volume_hierarchy.md)
- (Task 4) [Path Tracing](/docs/pathtracer/path_tracing.md)
- (Task 5) [Materials](/docs/pathtracer/materials.md)
- (Task 6) [Direct Lighting](/docs/pathtracer/direct_lighting.md)
- (Task 7) [Environment Lighting](/docs/pathtracer/environment_lighting.md)


Hui Wang's avatar
Hui Wang committed
26
27
28
29
30
31
32
33
34
# Operation Guide


1. Compile and run Scotty3D
2. In `Layout` mode (which is the default mode when you first open Scotty3D), click `Import Scene` to import the scene with the preset camera from `/media`. We recommand you to start with simple models as primary test cases, such as `cbox.dae`. To create your own scene, don't forget to add `New Light`. 
3. Switch to `Render` mode, set the camera in `Camera Settings` menu. If you imported the scene from `/media`, there should be a preset camera rendered as the black wireframe in the window. 
4. Select the object in `Menu` and adjust its pose, mesh and material in `Object Options`.
5. Open the render window by clicking `Open Render Window`, setup the render image.
6. Click `Start Render` to render your image. 
Hui Wang's avatar
Hui Wang committed
35
    - It may take some time to render your image, as the duration of the rendering process is highly dependent on the complexity of your scene (number of primitives), the image resolution, the number of samples per pixel, and the max ray depth. For example, rendering a `640x360` image of `cbox.dae` with 4 samples per pixel and 8 max ray depth takes 1.2s on an i7-8750H laptop, while rendering `cow.dae` with a single directional light under the same image setting takes approximately 10s.
Hui Wang's avatar
Hui Wang committed
36
37
38
39
40
41
    - When debugging, we recommend rendering a coarse image with a low number of samples per pixel and a low image resolution, which could save a considerable amount of waiting time.
7. Once you have created your own scene, you can export it by clicking `Export Scene` in `Layout` mode.

See Render Mode for more details.

# Code Structure
Hesper Yin's avatar
Hesper Yin committed
42

yhesper's avatar
yhesper committed
43
44
The files that you will work with for PathTracer are all under `src/student` directory. Some of the particularly important ones are outlined below. Methods that we expect you to implement are marked with "TODO (PathTracer)", which you may search for.

TheNumbat's avatar
TheNumbat committed
45
You are also provided with some very useful debugging tool in `src/student/debug.h` and `src/student/debug.cpp`. Please read the comments in those two files to learn how to use them effectively.
Hesper Yin's avatar
Hesper Yin committed
46

yhesper's avatar
yhesper committed
47
48
49
50
| File(s)  |      Purpose      |  Need to modify? |
|----------|-------------------|------------------|
| `student/pathtracer.cpp` |  This is the main workhorse class. Inside the ray tracer class everything begins with the method `Pathtracer::trace_pixel` in pathtracer.cpp. This method computes the value of the specified pixel in the output image. | Yes |
| `student/camera.cpp` | You will need to modify `Camera::generate_ray` in Part 1 of the assignment to generate the camera rays that are sent out into the scene. |  Yes |
TheNumbat's avatar
TheNumbat committed
51
| `student/tri_mesh.cpp`, `student/shapes.cpp`, `student/bbox.cpp` | Scene objects (e.g., triangles and spheres) are instances of the `Object` class interface defined in `rays/object.h`. You will need to implement the `bbox` and intersect routine `hit` for both triangles and spheres. |   Yes |
TheNumbat's avatar
TheNumbat committed
52
|`student/bvh.inl`|A major portion of the first half of the assignment concerns implementing a bounding volume hierarchy (BVH) that accelerates ray-scene intersection queries. Note that a BVH is also an instance of the Object interface (A BVH is a scene object that itself contains other primitives.)|Yes|
yhesper's avatar
yhesper committed
53
54
55
56
57
58
|`rays/light.h`|Describes lights in the scene. The initial starter code has working implementations of directional lights and constant hemispherical lights.|No|
|`lib/spectrum.h`|Light energy is represented by instances of the Spectrum class. While it's tempting, we encourage you to avoid thinking of spectrums as colors -- think of them as a measurement of energy over many wavelengths. Although our current implementation only represents spectrums by red, green, and blue components (much like the RGB representations of color you've used previously in this class), this abstraction makes it possible to consider other implementations of spectrum in the future. Spectrums can be converted into a vector using the `Spectrum::to_vec` method.| No|
|`student/bsdf.cpp`|Contains implementations of several BSDFs (diffuse, mirror, glass). For each, you will define the distribution of the BSDF and write a method to sample from that distribution.|Yes|
|`student/samplers.cpp`|When implementing raytracing and environment light, we often want to sample randomly from a hemisphere, uniform grid, or shphere. This file contains various functions that simulate such random sampling.|Yes|