Hi,

is there any way how to set node transform in visitor program?

I need it for motion blur effect where I must interpolate transform matrix for each ray with different seed.

Or any other suggestion how to do transform interpolation?

The visitor program is not the right place to modify geometry intersections. That only picks which sub-tree to traverse and changing transforms on geometry of a sub-tree can only be done via the host API and requires rebuild/refit of acceleration structures.

Stochastic motion blur is something you would normally do inside the intersection program.

You need to make the matrices which transform the geometry available to the intersection program and calculate the position of the intersection based on some time at which you sample the ray.

Unfortunately the current per ray payload is not available inside the intersection program, but the launch index is, so you could use an input_output buffer to write the current time or matrix weight per launch index inside the ray generation program once before calling any rtTrace and read that inside the intersection program to be able to transform the geometry to the location matching the ray’s time.

As prerequisite, to be able to hit something which is moving, the acceleration structure would need to be build around the whole motion vector of the object.

Means the bounding box program would also need the matrices and build axis aligned bounding boxes around the extends of the full motion vector of each primitive.

This will make the bounding boxes bigger than for static geometry and as a result many ray intersection tests will miss the geometry inside the bounding box which can make the whole rendering process a lot slower depending on the motion vectors and time slices.

Some care needs to be taken for getting the bounding boxes right for arbitrary transformations since you won’t sample infinitely many time steps inside the bounding box program.

Hi, thank you for your reply.

Your solution is fine for object deformations, unfortunately for transforms no (maybe only one ;(

In case of instancing I must to have acceleration structure for each instance (is there a way, how to generate more than one acceleration structure over same geometry? One solution is create more optix::Geometry objects and share its vertex buffers).

Another problem is, that I must reimplement all rtTransform* functions by own with same functionality even if I know resulting matrix in intersection/material program.

Also I can compute this interpolated matrix only one time per ray, not for each triangle, so visit program should be the right place for this (for moved object I can create visitor nodes without acceleration structures and having a bounding box and matrices I can compute interpolated matrix and do instersection against transformed AABB). Problem is, that OptiX don’t support update ray by this matrix (acceleration structure don’t need to be updated).

The transformations which need to be done inside the bounding box and intersection programs are based on user data and of course does that support arbitrary transformation hierarchies if you provide the necessary user data and program code to calculate the primitive locations.

Yes, that won’t work with real instances via Transform nodes. The individual geometries which move need to know the transformation over time and that means they need to have a different parameter to identify their unique transformation, unless all your instances have the same transformation.

You answered yourself why your ideas are not going to work. rtCurrentRay is read-only so you wouldn’t be able to inverse transform the ray.

My recommendation remains the same if you want to try stochastic motion blur.

Maybe it’s too slow after all and you might try rendering many individual time steps like the OptiX SDK cook-motion-blur example instead.

I implemented stochastic MB for object deformations. It is suitable for small deformations, not for transformations over whole object where each triangle have bounding box over whole object.

Is there some possibility to add editable program for transform node in some future OptiX release?

Or add extra parameter into rtIntersectChild() function in visit program - matrix.