Merge static objects into one tree: rays leaving surfaces up to 1.75× faster

Open
#53 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
three.js, typescript, web-dev

Research direction

Start by reading the scene tree construction and the walk-equivalence test; the issue does not name their file paths. Build a merged tree for static, non-instanced geometry while retaining instancing for moving or repeated objects, and determine whether the change belongs here or in @pmndrs/bvh. Done means the walk-equivalence test passes and performance is re-timed on an RTX 3060 and in DDGI and radiance cache ray passes.

Written by the indexing model from the issue text.

Description

enhancement

Rays that leave a surface trace much slower than rays that start in the air. The cause is the top level of the scene's trees: the boxes around separate objects overlap, so a ray leaving a surface enters many objects it never hits.

Merging the static objects into one tree fixes most of it. Measured on the Apple M5 Pro at main (#52, bench/results/surface-rays-m5.csv; pages trace-bench-surface-sponza and trace-bench-surface-bistro-interior):

Scene Closest hit, merged vs instanced Any hit Steps per ray, instanced → merged
Sponza 1.75× (runs 1.71–1.85) 1.36× 113.8 → 70.3
Bistro interior 1.19× (runs 1.15–1.26) 1.14× 114.3 → 101.4

The Mac's archived track (archive/mac-radiance-cache, its RC5.4) measured 1.86× and 1.24× with the same step counts.

To do:

  • Build one merged tree for static, non-instanced geometry and keep instancing for objects that move or repeat. Decide where this belongs: here or in @pmndrs/bvh.
  • Keep the walk-equivalence test passing.
  • Re-time on the RTX 3060, then on DDGI's and the radiance cache's real ray passes, not only the bench.
Dominant language
TypeScript
Stars
0
Forks
0
Avg merge
16h 11m
Merged PRs (30d)
15

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pmndrs/gi

All issues in pmndrs/gi

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.