Skip to content

Commit c545a59

Browse files
committed
fixes lookAt calculation for loading toWorld property in mitsuba scene
1 parent cb13a6b commit c545a59

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/nbl/ext/MitsubaLoader/PropertyElement.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,14 @@ std::optional<SNamedPropertyElement> CPropertyElementManager::createPropertyData
258258
up[index] = 1.f;
259259
}
260260
// TODO: after the rm-core matrix PR we need to get rid of the tranpose (I transpose only because of GLM and HLSL mixup)
261-
const auto lookAtGLM = reinterpret_cast<const hlsl::float32_t4x4&>(glm::lookAtLH<float>(origin,target,up));
262-
const auto lookAt = hlsl::transpose(lookAtGLM);
261+
//const auto lookAtGLM = reinterpret_cast<const hlsl::float32_t4x4&>(glm::lookAtLH<float>(origin,target,up));
262+
//const auto lookAt = hlsl::transpose(lookAtGLM);
263+
const auto lookAt = hlsl::math::linalg::rhLookAt(origin, target, up);
263264
// mitsuba understands look-at and right-handed camera little bit differently than I do
264265
const auto rotation = hlsl::inverse(hlsl::float32_t3x3(lookAt));
266+
for (auto i = 0; i < 3; i++)
267+
for (auto j = 0; j < 3; j++)
268+
result.mvalue[i][j] = rotation[i][j];
265269
// set the origin to avoid numerical issues
266270
for (auto r=0; r<3; r++)
267271
{

0 commit comments

Comments
 (0)