I was trying to create a render buffer where I can for example, just write some data for each mesh. For this, I use a MultiRenderTarget.
Now in onBeforeRender of the renderTarget, I assign a unique custom shader material for each mesh, and restore the original material back later in onAfterRender.
Then using onBeforeRenderObservable callback available on a mesh, I assign some uniforms to the custom material.
All of this works fine.
But I wanted to optimize this, and rather than creating a custom material for each mesh, I want to have a single custom material, and just change the uniforms before rendering the mesh.
However this doesn’t really work.
So my question is, how can I tell babyloneJS to update/refresh uniforms of a material before rendering the mesh.