No viewProjectionR
is declared, but used here: Babylon.js/packages/dev/core/src/Shaders/pbr.vertex.fx at master · BabylonJS/Babylon.js · GitHub.
To fix this issue in pbrVertexDeclaration.fx
:
#ifdef MULTIVIEW
uniform mat4 viewProjectionR;
#endif
No viewProjectionR
is declared, but used here: Babylon.js/packages/dev/core/src/Shaders/pbr.vertex.fx at master · BabylonJS/Babylon.js · GitHub.
To fix this issue in pbrVertexDeclaration.fx
:
#ifdef MULTIVIEW
uniform mat4 viewProjectionR;
#endif
It is actually declared here:
Babylon.js/packages/dev/core/src/Shaders/ShadersInclude/sceneFragmentDeclaration.fx at master · BabylonJS/Babylon.js
or here if UBO:
Babylon.js/packages/dev/core/src/Shaders/ShadersInclude/sceneUboDeclaration.fx at master · BabylonJS/Babylon.js
And imported from there:
Babylon.js/packages/dev/core/src/Shaders/pbr.fragment.fx at master · BabylonJS/Babylon.js
I think this matrix should be in vertex shader
It is ALSO there:
Babylon.js/packages/dev/core/src/Shaders/pbr.vertex.fx at master · BabylonJS/Babylon.js
pointing to:
Babylon.js/packages/dev/core/src/Shaders/ShadersInclude/sceneVertexDeclaration.fx at master · BabylonJS/Babylon.js
If the above is the correct lines to process the __decl__
include files, the #include<__decl__pbrVertex>
at the “pbr.vertex.fx” will point to “pbrVertexDeclaration.fx” instead of “sceneVertexDeclaration.fx”.
And this patch(core: fix missing viewProjectionR decl for multiview in shaders · M-CreativeLab/Babylon.js@3cf42f0 · GitHub) fixes the program linking problems in my device.
ok maybe I do not understand the core problem
can you share a repro that shows we have a problem?
So far I’m not aware of a bug so this may help me realize what is going on
Ok I dug more and you are TOTALLY right! something is missing. I would just need a repro case to add a test so we do not miss that again. Can you repro in the PG?
Thanks for your reply and confirmation. However, reproducing this issue in the Playground (PG) is quite challenging due to the specific environment required. This issue occurs specifically in Web runtimes that have the WebGL ovr_multiview2
extension and have Uniform Buffer Objects (UBOs) disabled (such as engine.disableUniformBuffers = true
). Under these conditions, the Effect
will use definitions like those in pbrVertexDeclaration, otherwise it will use sceneVertexDeclaration. That’s why Babylon.js works correctly in most browser environments.
I encountered this issue while developing a new WebXR runtime that renders one or more WebXR applications (including Babylon.js apps) and a host environment (like Unity or UE) simultaneously in the same scene, viewed through an XR headset or glasses. To address rendering latency in this scenario, I temporarily disabled WebGL UBOs and discovered this problem.
In addition to this issue, I found that viewProjectionR
was also not set correctly in this environment, so I added another patch to resolve it: core: update viewProjectionR for multiview rendering if uniform is un… · M-CreativeLab/Babylon.js@48cb6fe · GitHub
If you’re open to it, I’d be happy to submit these 2 patches as separate Pull Requests to Babylon.js, but I would appreciate some guidance on how to add corresponding regression tests and others required
I actually did the first PR already
Fix missing matrix by deltakosh · Pull Request #15745 · BabylonJS/Babylon.js
Please send the second one
For the regression test, you need to add a new PG here:
Babylon.js/packages/tools/tests/test/visualization/config.json at master · BabylonJS/Babylon.js
And store the reference here:
Babylon.js/packages/tools/tests/test/visualization/ReferenceImages at master · BabylonJS/Babylon.js
Thank you, that’s great!
BTW, do you guide me how to enable multiview in PG?
Cc @RaananW for that part;)