Substance Material - Clone at Runtime (Mobile)

Hello,

I want to be able to have 40 Instances of my model but each with unique colours that is generated by script, at runtime.

The issue I’m running into is a massive overhaul on memory (this is running on the latest iPhone).

Firstly, I’ve duplicated by model 40 times, and placed in a grid. I then need to clone from the master ProceduralMaterial in order to be able to uniquely change properties for each individual model. I do this by calling this on every instance of my model:

//gets the master from this renderer object
_clone = (ProceduralMaterial)_renderer.material;
//apply the new clone to this renderer object
_renderer.material = _clone;
//change a property on the clone material
_clone.SetProceduralColor("some_property", _randomColor);
//and build
_clone.RebuildTextures();

This works, however the memory usage increases massively (from 115Mb to nearly 300Mb). The Substance Material has a Generated Texture applied to it.

Is this spike in memory because of Substance having to Duplicate this Texture each time I clone the material?

Thanks.

Hi,i’m substance designer user.Each time you change properties of substance during runtime it will every time rebuild whole graph(so it is wise for realtime changes with substances to have really well optimized substance for such usage-quck generation of textures).Problem you have is 40 models=40 substance instances = 40* whole texture set each time. It is massive in case of generating all that textures and even when calculated you will have crazy amount of textures.Depending on world size and importance and camera distance from the 3D object you should join all 3D objects into one substance and create masks inside graph which will help you to separate colors for every 3D object.If you don’t need to generate all objects textures in realtime in front of players eyes then you can specify when they will rebuild and on such way you can scatter processing power while they generate
textures(generate -if in player range,generate after “x” seconds and so on…).If you doing some optimization for 3D objects for example if you spawn object and generate texture,you record texture into device solid drive,then you unload such texture and do everything again with next 3D object