← Back to context

Comment by pclmulqdq

3 days ago

No, searching the set of triangles in the scene to find an intersection takes non-constant time.

I believe with an existing BVH acceleration structure, the average case time complexity is O(log n) for n triangles. So not constant, but logarithmic. Though for animated geometry the BVH needs to be rebuilt for each frame, which might be significantly more expensive depending on the time complexity of BVH builds.

  • Yeah, this search is O(log n) and can be hardware-accelerated, but there's no O(1) way to do this.

    • It's also only O(log n) if the scene is static. Which is what is often missed in the quest for more photo-realistic graphics - it doesn't mean anything if what you are rendering only looks realistic in still frames but doesn't behave realistically if you try to interact with it.

    • What if we keep the number of triangles constant per pixel, independently of scene complexity, through something like virtualized geometry? Though this would then require rebuilding part of the BVH each frame, even for static scenes, which is probably not a constant operation.

    • For static geometry we could but for animated geometry or dynamic geometry it would have to be calculated during a mesh shader step.