Hello all;
I’m experimenting with a Blueprint that creates a unique texture (using ‘Substance’) for each static mesh added to the scene.
I have made a function that creates a substance graph instance with a random seed, and assigns the outputs to a dynamic material instance. The function looks like this:
For my first test, I’m calling the function like this, as part of a basic ‘Scatter’ blueprint:
In this case, there are only 10 different substance seeds, but a dynamic material instance for EVERY static mesh component. I’ve tested up to 10,000 scattered objects - so presumably 10,000 dynamic material Instances. The editor was <1 f/sec on a GeForce 775M. Obviously not usable, but I was surprised that was even possible.
Oddly, performance seems to be better when I have fewer random seeds - which would suggest that Unreal has figured out that most of the Substance outputs are identical to each other, and hasn’t created 10,000 individual texture files. That would be VERY impressive if that were true - but I can’t figure out how Unreal would do this. I tried to find the dynamic materials that had been created in the content browser (to find out how many of them there were), but they seem to be hidden.
Assuming Unreal is creating 10,000 textures from only 10 seeds, the logical workflow would be to create 10 dynamic materials (1 for each Substance seed), and then randomly pick one to assign to each Static Mesh. This would involve knowing what Dynamic Material Instances already exist - and which Substance Factory created them. It wouldn’t be too hard to do this if it was possible to re-name the Material Instances after they are created - then I could reference a DMI called something like ‘substanceA_seed8’ when I need it in future. There doesn’t seem to be any way of doing this in Blueprint - I get a whole list of DMIs called ‘DynamicMaterialInstance_4987’ etc. with no way of knowing where it came from.
I’ve therefore got a couple of Blueprint / material workflow questions, and it would be great if anyone with more knowledge than me could give some advice:
TL/DR:
>Where are dynamic material instances / textures stored? They seem to be hidden when created through a blueprint, so I can’t tell how many of them there are.
>Does Unreal do something clever to check for functionally identical textures or shaders, in order to speed up performance?
>Is it possible to rename material instances in Blueprint, or dynamically create variables I can reference in other Blueprints?
>Is 10,000+ Dynamic Material Instances completely out of the question on a modern graphics card? I’m using this for cinematics, so fps isn’t as important as it would be for other projects.