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

Rewrite BVH generation to run faster/handle larger models #2

Open
umar-ahmed opened this issue Feb 4, 2024 · 1 comment
Open

Rewrite BVH generation to run faster/handle larger models #2

umar-ahmed opened this issue Feb 4, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@umar-ahmed
Copy link
Owner

Context

The current version of BVH construction is written in a ~150 lines of TypeScript code. This code works well for small models, but for larger models, the page hangs for a bit and becomes unresponsive.

There are a few options I've considered to move forward:

  1. Move the existing TypeScript code to a Web Worker: This would free up the main thread and not cause locking. It wouldn't really make the process go faster, but might avoid some crashes
  2. Rewrite the code in a more efficient language like C++ or Rust and compile to WASM: We can take advantage of compiler optimizations and eke out a bit more performance.
  3. Construct the BVH on the GPU: Using the approach described in this series of blog posts by NVIDIA: https://developer.nvidia.com/blog/thinking-parallel-part-iii-tree-construction-gpu/ , we can construct a Linear BVH on the GPU using the concept of Morton codes to spatially sort the bounding boxes.

Existing Code

https://github.com/umar-ahmed/webgpu-pathtracer/blob/main/src%2Fpasses%2Fraytrace.ts#L511-L631

@umar-ahmed umar-ahmed added the enhancement New feature or request label Feb 4, 2024
@umar-ahmed
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant