Freezing node material with triplanar nodes results in deformed meshes

I’m using a node material containing TriPlanar nodes. It works great but when I invoke freeze() on it from the onAfterRenderObservable callback, some of the meshes using the material get deformed in an arbitrary manner (e.g. missing faces, vertices show up in the wrong places, and so on).

I tried to call markDirty(true) to fix the problem without avail. The only remedy seems to be unfreezing the material.

Any kind of information that could help me debug the problem would be appreciated.


Would you be able to provide a repro?

It seems to work fine in this PG:

1 Like

Sorry for the late response. I tried to narrow down the problem and found that it wasn’t a TriPlanarBlock that was causing the problem but a BonesBlock.

Specifically, I found that the symptom appears when I freeze a node material containing BonesBlock, which converts the world matrix to calculate world position and normal for other nodes.

And I suspect it only happens when the material is shared across different meshes which are deformed by changing bone (actually a linked transform node since it’s imported from a GLTF source) positions.

Unfortunately, I’m unable to produce a minimal reproducible scene at the moment. But if I manage to narrow down the issue further and replace all the proprietary code and models involved with something I can upload to PG, I’ll let you know.


After more tests, I can now confirm that the problem only occurs when the node material in question is shared between different meshes each deformed by a skeleton. I still have little clue as to how to fix this problem though.

Before calling “freeze()”:

After calling “freeze()”:

Try to clone the material so that each mesh has its own material instance.

If you can provide a minimal reproduction in the Playground, we could have a deeper look.

I already made a version which instantiates new material for each mesh from the source so it was trivial to test what you suggested. It fixed the deformation problem but was too slow to be used for my project.

And wow, cloning the material solved the performance issue as well!

Thanks much for the help! I’ve been wrestling with this problem for quite sometime and now I can sleep well at night :wink: