Skip to content

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

Description

@umar-ahmed

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions