Per mesh projection matrix

Hi!

Is there a possibility to change the projection matrix individually for each mesh that’s being rendered? To be clear, I don’t want to update the proj matrix of the camera once per render-cycle for all meshes but instead update it for each mesh individually (so that all uniforms that contain the proj matrix in any form, like the MVP, are sent to the GPU again).

I’ve tried to register an onBeforeRenderObservable observer on the mesh, update the camera proj matrix accordingly and set it back to normal in the onAfterRenderObservable but this didn’t work as expected. Instead of updating the matrix only for this one render call of this one mesh, it updated it for all meshes.

Is there a way to work around this without using a custom shader material? Thx in advance!

You will need to instruct the system to bind the scene uniform buffer with the updated projection matrix:

https://playground.babylonjs.com/#Z0HPDK

It’s a bit of an edge case as _needToBindSceneUbo is not supposed to be modified by the end user…

1 Like

Thx a lot - works as expected!