Skip to content

Commit 84bab56

Browse files
wjakoblnuic
andauthored
Simplified OptiX intersection programs (#1563)
The OptiX intersection programs for various shapes contained an unnecessary world <-> object space transformation. This step was not only unnecessary, but it generates a shockingly large amount of code related to OptiX motion transforms and all sorts of features that we are to using at all. All of this logic consumes registers, which has a negative impact on occupancy of generated kernels. This commit incorporates a small change to the `get_ray()` function and adapts the other intersection programs, which brings `optix_rt.ptx` to 14% of its current size. * SDFGrid: Consider ray's mint (#1564) * updated PTX code --------- Co-authored-by: Lovro Nuic <12744626+lnuic@users.noreply.github.com>
1 parent 71276ab commit 84bab56

File tree

7 files changed

+941
-7718
lines changed

7 files changed

+941
-7718
lines changed

include/mitsuba/render/optix/ray.cuh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace optix {
99
struct Ray3f {
1010
Vector3f o; /// Ray origin
1111
Vector3f d; /// Ray direction
12+
float mint; /// Minimum position on the ray segment
1213
float maxt; /// Maximum position on the ray segment
1314
float time; /// Time value associated with this ray
1415

@@ -25,13 +26,10 @@ struct Ray3f {
2526
/// Returns the current ray in instance space (based on the current instance transformation)
2627
DEVICE Ray3f get_ray() {
2728
Ray3f ray;
28-
ray.o = make_vector3f(optixTransformPointFromWorldToObjectSpace(optixGetWorldRayOrigin()));
29-
ray.d = make_vector3f(optixTransformVectorFromWorldToObjectSpace(optixGetWorldRayDirection()));
30-
31-
float mint = optixGetRayTmin();
32-
ray.maxt = optixGetRayTmax() - mint;
33-
ray.o += ray.d * mint;
34-
29+
ray.o = make_vector3f(optixGetObjectRayOrigin());
30+
ray.d = make_vector3f(optixGetObjectRayDirection());
31+
ray.mint = 0.0f; // Rays cast by Mitsuba always have mint==0.
32+
ray.maxt = optixGetRayTmax();
3533
ray.time = optixGetRayTime();
3634
return ray;
3735
}

0 commit comments

Comments
 (0)