Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Tags in this Discussion

How rtTransform* works?
  • I didn't understand how the rtTransform* functions from OptiX API works, I mean, I do know what they do, but I didn't get how to use the functions.

    Supose the following scenario:

    A scene composed by two objects, both defined in world space (which means the model matrix for both objects are the identity, right?). A camera positioned in (x,y,z)=(10, 10, 10) pointing to (x,y,z)=(0,0,0) also defined in world space.

    With this stated, if I launch rays from that camera, using the view space, I need to transform the rays from view-to-world space right? But how optix will know which matrix to use in order to do this transformation when using rtTransformVector/Point?

    I think a more general question would be how optix knows which matrix to apply to point, vectors or normals when using rtTransform* functions?
  • 3 Comments sorted by
  • You specified your scene in world coordinates and you generate your rays in world coordinates. There is no view space, or if you defined one for yourself it's your task to convert the started rays in the ray generation program to world space.

    Please have a look through the OptiX_Programming_Guide_2.5.0.pdf which explaines which coordinate space is used in which program domain in Table 6 Space of rtCurrentRay for Each Program Type

    The rtTransform*() calls explained directly below that table come in the necessary variants which define if coordinates should be transformed as Point (4D, w == 1.0) , as Vector (4D, w == 0.0) or as Normal (4D Inverse Transpose, w == 0.0) and you define which matrix to use with RT_OBJECT_TO_WORLD or RT_WORLD_TO_OBJECT.
    As you see there is no view coordinate space, only object/model space and world space in OptiX.

    The attributes should be interpolated in model space in your intersection program and it's your task to transform them into world space in the closest hit program for example and you know which attribute needs to be transformed how.
  • Thanks for the answer.

    I actually mixed the concepts of view-space and object-space. I just get a little bit confused in where the transformation matrix is set. According to the documentation, this transform matrix changed only when traversing a transform node. If I defined my objects in world-space there is no need to transform normals , for instance, right?
  • Vote Up0Vote Down Detlef Roettger
    Posts: 330 Accepted Answer
    If you do not have transforms above them, there shouldn't be a need to do the usual
    float3 world_shading_normal = normalize(rtTransformNormal(RT_OBJECT_TO_WORLD, shading_normal));
    Try if that is in any way performance relevant in your case, because it's better to be safe than sorry when you move code from one application to another which might behave differently.