Dynamic Batch Group + Unticked Preload leads to Placeholder Materials

Hi everyone,

we recently encountered a problem with batch groups which are marked as dynamic in the editor:
If the texture of a material that is batched into a dynamic group is set to not preload, the batched MeshInstances will never update their materials to use the actual texture once it is loaded. The meshes will indefinitely keep their placeholder material textures that were assigned on creation of the material.

I have had a look through the engine code and think that the root cause is that the material of a batch group is cloned on batch group creation here:

If the textures are not loaded at this point, this will clone a material with placeholder textures. When the texture is finally loaded, only the original material (not the cloned one) will be updated and the batch group is not automatically regenerated

I have created a project reproducing this issue here:
https://playcanvas.com/project/978563/overview/dynamic-batching-placeholder-mat

Is this an expected behaviour, or is this a bug?
Are we expected to manually regenerate batch groups once all the textures of materials of models with dynamic batch groups are loaded?

As always, thank you very much for your help!

3 Likes

@mvaligursky is probably best placed to answer this :slight_smile:

1 Like

It’s a known issue https://github.com/playcanvas/engine/issues/4262
I think the workaround you suggested is probably the best and easy to use option in the meantime.

4 Likes

I see, thanks for the link and quick feedback!