Using a infinite sphere

Hi,

I want to unify calculation for the implicit light path hitting environment (infinite sphere) to the calculation of ordinary surfaces.
I think good solution is defining intersection/bounding box programs for infinite sphere and using code path for the calculation of implicit path hitting ordinary surfaces instead of writing calculation as miss program.

However I’m afraid of that using bounding box program returning infinite(-inf to inf or -FLT_MAX to FLT_MAX) bounds affects performance because TRBVH uses LBVH as basis and morton code calculation in LBVH uses bounding box of entire scene.

Is this apprehension true for TRBVH implementation in OptiX?

Yes, adding a huge bounding box to the Bvh for the infinite sphere will add at least a slight overhead during ray intersection for 1 extra ray-box test. You could improve on this by calculating the real bounding box of the scene and then creating a “miss” box that is only slightly larger (not inf or flt_max).

What is your motivation to unify the closest-hit and miss programs? Just for code cleanliness, or do you think having the same program will increase coherence?

Thanks for the reply.

Both. I will have an overhead a bit due to abstraction to correctly handle inifinite distance, but I expect unifying code path of implicit light path hitting a light source (ordinary surface light and environment (infinite sphere) light) to improve performance.

This is inevitable and I must accept.

I think LBVH first quantizes primitives’ coordinates by dividing space in the entire scene AABB into 2^N cells (for each dimension).
If the entire scene AABB is very very large, almost all primitives belong to the same cell.
This seems to introduce serious performance degradation.

This is my concern.
Should I use another builder like Bvh?
(Can I avoid the performance degradation due to the infinite sphere?)

Yes, what about the workaround of making your “infinite” sphere geometry a tight bound for the rest of the scene? You just need the ray direction, so a sphere of any size larger than that minimal sphere should give the same result. Unless I’m missing something.

As far as how or whether Trbvh does initial binning, I’m not sure I can publicly answer that even if I knew :)

That workaround seems good for secondary rays or beyond, but how about primary rays?
Now I think a new way like the following

Group
(NoAccel)
/ . . . . . . .
GeomGroup . . . . . . . .Group
. (Inf Sphere) . . . . . . . . (Scene)

This increases the layer of scene graph but seems good if an overhead is small.
I will try this.

This will always test against the Inf Sphere group, even if the ray hits other geometry. I’m curious to see if this is any more efficient in practice than a miss shader.