|
9 | 9 |
|
10 | 10 |  |
11 | 11 |
|
12 | | -<p align="center">A large mineway castle shade with one Disney BRDF material (6,490,766 triangles)</p> |
| 12 | +<p align="center">A large mineway castle shaded with one Disney BRDF material (6,490,766 triangles, 300 spp, 6.1 fps)</p> |
13 | 13 |
|
14 | 14 |  |
15 | 15 |
|
16 | | -<p align="center">A stanford dragon shade with refract material</p> |
| 16 | +<p align="center">A stanford dragon shaded with refract material</p> |
17 | 17 |
|
18 | 18 | ## Features Implemented: |
19 | 19 |
|
|
27 | 27 |
|
28 | 28 | # Bounding Volume Hierarchy |
29 | 29 |
|
30 | | -The base code shoot rays out from the camera and intersect each object in the scene. |
| 30 | +The base code shoots rays out from the camera and compute intersections with all objects in the scene. |
31 | 31 |
|
32 | | -After mesh loading feature is implemented, the way of light-scene intersection is changed from calculating |
33 | | -intersection with implicit geometries to calculating it with all triangles! Which gives an extremely low frame rate |
34 | | -when model with many faces is loaded: |
| 32 | +This works fine when we can implicitly define intersecting method for each geometry (just like SDF). But after mesh loading feature is implemented, the way of light-scene intersection is changed from calculating |
| 33 | +intersection with implicit geometries to calculating it with all triangles! |
| 34 | + |
| 35 | +This gives an extremely low performance when model with many faces is loaded: |
35 | 36 | | < 200 faces (~60 fps) | ~6000 faces (< 10 fps) | |
36 | | -| -------------------------------------|-------------------------- | |
37 | | -| | | |
| 37 | +| -------------------------------- | ------------------------------- | |
| 38 | +|  |  | |
| 39 | + |
| 40 | +To effectively reduce the amout of intersection computation, we could use BVH, Bounding Volume Hierarchy, which construct |
| 41 | +a tree-like structure to store scene primitives. |
| 42 | + |
| 43 | +The efficiency of BVH depends on how we build the tree. There are many ways to segment triangls, for this project, I used HLBVH, which is a combination of Surface Area Heuristic (SAH) and morton code based Linear BVH. For more reference, check [PBRT 4.3 Bounding Volume Hierarchy](https://pbr-book.org/3ed-2018/Primitives_and_Intersection_Acceleration/Bounding_Volume_Hierarchies). |
| 44 | + |
| 45 | +And this gives a very good speed up |
| 46 | + |
| 47 | +| Before BVH (< 10 fps) | After BVH (~30 fps) | |
| 48 | +| ------------------------------- | ----------------------------- | |
| 49 | +|  |  | |
| 50 | + |
| 51 | +We can go even further with a stanford dragon (2,349,078 triangles) |
| 52 | + |
| 53 | +| Dragon ( 15 fps) | |
| 54 | +| --------------------------- | |
| 55 | +|  | |
| 56 | + |
| 57 | +Visualizer: |
| 58 | +| Wahoo | Dragon | Mineway Castle | |
| 59 | +| 5117 triangles | 2,349,078 triangles | 6,490,766 triangles | |
| 60 | +| ------------------------------- | ----------------------------- | --------------------------- | |
| 61 | +|  |  |  | |
0 commit comments