Skip to content
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

Surface Area Heuristic for Bounding Value Hierarchy structures #208

Merged
merged 50 commits into from
Jul 28, 2024

Conversation

Walther
Copy link
Owner

@Walther Walther commented Jun 22, 2024

Implementing the Surface Area Heuristic algorithm for Bounding Volume Hierarchy tree construction.

Based on these two blog articles:

The new SAH algorithm results in much more efficient BVH trees. This affects especially scenes with a larger amount of primitives.

hyperfine -L bvh lam,sah "just cli render -w 1920 -h 1080 --sampler blue --samples 8 --bvh {bvh} -o temp.png ~/sponza.json"
Benchmark 1: just cli render -w 1920 -h 1080 --sampler blue --samples 8 --bvh lam -o temp.png ~/sponza.json
  Time (mean ± σ):     52.065 s ±  0.318 s    [User: 387.275 s, System: 0.751 s]
  Range (min … max):   51.794 s … 52.789 s    10 runs
 
Benchmark 2: just cli render -w 1920 -h 1080 --sampler blue --samples 8 --bvh sah -o temp.png ~/sponza.json
  Time (mean ± σ):     20.147 s ±  0.050 s    [User: 141.036 s, System: 0.381 s]
  Range (min … max):   20.090 s … 20.255 s    10 runs
 
Summary
  just cli render -w 1920 -h 1080 --sampler blue --samples 8 --bvh sah -o temp.png ~/sponza.json ran
    2.58 ± 0.02 times faster than just cli render -w 1920 -h 1080 --sampler blue --samples 8 --bvh lam -o temp.png ~/sponza.json
hyperfine -L bvh lam,sah   5283.53s user 11.72s system 733% cpu 12:02.34 total

There's also a couple of new debug rendering modes, for visualizing the BVH node test count and primitive test count needed per pixel.

Before, with Longest Axis Midpoint BVH construction
1722156865

After, with Surface Area Heuristic BVH construction
1722156858

Colorization key
Screenshot 2024-07-28 at 12 22 35

earlier returns based on the distances to the child nodes' axis-aligned bounding boxes. rays no longer need to traverse all the way through objects to return the closest hitpoint
@Walther Walther changed the title 2024-06 BVH improvements Surface Area Heuristic for Bounding Volume Hierarchies Jul 28, 2024
@Walther Walther merged commit 34b838f into main Jul 28, 2024
4 checks passed
@Walther Walther deleted the 2024-06-bvh-improvements branch July 28, 2024 10:16
@Walther Walther changed the title Surface Area Heuristic for Bounding Volume Hierarchies Surface Area Heuristic for Bounding Value Hierarchy structures Jul 28, 2024
@Walther Walther mentioned this pull request Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant