When translating from eye space to world space (or vice-versa) in OptiX, we can use the UVW vectors to build a rotation matrix. My question is (or it’s actually a confirmation I’m seeking), that to create a correct rotation matrix, one has to flip the W vector since the coordinates system has to match.
Normally (in my case too), the UVW vectors build a projection with U right, V top, and W out of the screen. This means that UVW vectors build a left-handed space (matrix). Since all vectors in OptiX are defined in the RHS, we need to flip W to get an RHS matrix.
__device__ void rotateEyeToWorldCoordinates(float3& direction)
{
const float3 Un = normalize(U);
const float3 Vn = normalize(V);
const float3 Wn = -normalize(W);
const float viewMatData[9] = {Un.x, Un.y, Un.z,
Vn.x, Vn.y, Vn.z,
Wn.x, Wn.y, Wn.z};
const Matrix<3,3> viewMatrix(viewMatData);
direction = direction * viewMatrix;
}
Even though this might be a really basic question, I would like to get confirmation on this since I might have missed something → I did not find any flipping in the examples for the pinhole camera which made me wonder.