diff --git a/NEW_RELEASE_NOTES.md b/NEW_RELEASE_NOTES.md index 244ba1f826..ca69d30b12 100644 --- a/NEW_RELEASE_NOTES.md +++ b/NEW_RELEASE_NOTES.md @@ -7,3 +7,5 @@ We are chaning the way Vulkan buffers are handled. We need to switch over to a m appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md). ## Release notes for next branch cut + +- materials: added `getEyeFromViewMatrix()` for vertex shader [⚠️ **Recompile Materials**] \ No newline at end of file diff --git a/filament/src/ds/PerViewDescriptorSetUtils.cpp b/filament/src/ds/PerViewDescriptorSetUtils.cpp index 3d02e8cfb7..53863b996c 100644 --- a/filament/src/ds/PerViewDescriptorSetUtils.cpp +++ b/filament/src/ds/PerViewDescriptorSetUtils.cpp @@ -63,6 +63,7 @@ void PerViewDescriptorSetUtils::prepareCamera(PerViewUib& s, for (int i = 0; i < config.stereoscopicEyeCount; i++) { mat4f const& eyeFromHead = camera.eyeFromView[i]; // identity for monoscopic rendering mat4f const& clipFromEye = camera.eyeProjection[i]; + s.eyeFromViewMatrix[i] = eyeFromHead; // clipFromEye * eyeFromHead * headFromWorld s.clipFromWorldMatrix[i] = highPrecisionMultiply( clipFromEye, highPrecisionMultiply(eyeFromHead, headFromWorld)); diff --git a/libs/filabridge/include/private/filament/UibStructs.h b/libs/filabridge/include/private/filament/UibStructs.h index b9f449f673..6ea4232633 100644 --- a/libs/filabridge/include/private/filament/UibStructs.h +++ b/libs/filabridge/include/private/filament/UibStructs.h @@ -76,7 +76,8 @@ struct PerViewUib { // NOLINT(cppcoreguidelines-pro-type-member-init) math::mat4f worldFromViewMatrix; // clip view -> world : model matrix math::mat4f clipFromViewMatrix; // clip <- view world : projection matrix math::mat4f viewFromClipMatrix; // clip -> view world : inverse projection matrix - math::mat4f clipFromWorldMatrix[CONFIG_MAX_STEREOSCOPIC_EYES]; // clip <- view <- world + math::mat4f eyeFromViewMatrix[CONFIG_MAX_STEREOSCOPIC_EYES]; // clip eye <- view world + math::mat4f clipFromWorldMatrix[CONFIG_MAX_STEREOSCOPIC_EYES]; // clip <- eye <- view <- world math::mat4f worldFromClipMatrix; // clip -> view -> world math::mat4f userWorldFromWorldMatrix; // userWorld <- world math::float4 clipTransform; // [sx, sy, tx, ty] only used by VERTEX_DOMAIN_DEVICE @@ -212,8 +213,8 @@ struct PerViewUib { // NOLINT(cppcoreguidelines-pro-type-member-init) }; // 2 KiB == 128 float4s -static_assert(sizeof(PerViewUib) == sizeof(math::float4) * 128, - "PerViewUib should be exactly 2KiB"); +static_assert(sizeof(PerViewUib) == sizeof(math::float4) * 144, + "PerViewUib should be 16 x 144 bytes"); // ------------------------------------------------------------------------------------------------ // MARK: - diff --git a/libs/filamat/src/shaders/UibGenerator.cpp b/libs/filamat/src/shaders/UibGenerator.cpp index 1bb2417f2c..81bd222b43 100644 --- a/libs/filamat/src/shaders/UibGenerator.cpp +++ b/libs/filamat/src/shaders/UibGenerator.cpp @@ -99,6 +99,8 @@ BufferInterfaceBlock const& UibGenerator::getPerViewUib() noexcept { { "worldFromViewMatrix", 0, Type::MAT4, Precision::HIGH, FeatureLevel::FEATURE_LEVEL_0 }, { "clipFromViewMatrix", 0, Type::MAT4, Precision::HIGH, FeatureLevel::FEATURE_LEVEL_0 }, { "viewFromClipMatrix", 0, Type::MAT4, Precision::HIGH, FeatureLevel::FEATURE_LEVEL_0 }, + { "eyeFromViewMatrix", CONFIG_MAX_STEREOSCOPIC_EYES, + Type::MAT4, Precision::HIGH, FeatureLevel::FEATURE_LEVEL_0 }, { "clipFromWorldMatrix", CONFIG_MAX_STEREOSCOPIC_EYES, Type::MAT4, Precision::HIGH, FeatureLevel::FEATURE_LEVEL_0 }, { "worldFromClipMatrix", 0, Type::MAT4, Precision::HIGH, FeatureLevel::FEATURE_LEVEL_0 }, diff --git a/shaders/src/common_getters.glsl b/shaders/src/common_getters.glsl index 79cca65fb6..70540800ed 100644 --- a/shaders/src/common_getters.glsl +++ b/shaders/src/common_getters.glsl @@ -46,6 +46,11 @@ highp mat4 getViewFromClipMatrix() { return frameUniforms.viewFromClipMatrix; } +/** @public-api */ +highp mat4 getEyeFromViewMatrix() { + return frameUniforms.eyeFromViewMatrix[getEyeIndex()]; +} + /** @public-api */ highp mat4 getClipFromWorldMatrix() { return frameUniforms.clipFromWorldMatrix[getEyeIndex()];