- Home /
Substance Dynamic Texture Size
One of the key benefits of Substances or Procedural Materials as Unity refers to them, is to be resolution independent. Now I would really appreciate if I could set the target texture size at runtime. This would let me do some math based on client CPU, GPU and Screen Size do determine how big the textures need to be.
I can't find the property in the procedural material class. Does it mean it cannot be set at runtime ? Am I missing something ?
Answer by Jerc · Jul 10, 2012 at 07:01 AM
You can modify the resolution at runtime using "MySubstance.SetProceduralVector("$outputsize" ,new Vector4(9,9,9,9));"
9 being actually 2^9 = 512, so 10 will be 1024, etc.
It's not documented but it's there :)
I tried that. Nothing happens when I call for .SetProceduralVector("$outputsize", new Vector4(9,9,9,9)); When I query .GetProceduralVector("$outputsize");, I always get the same values as prior to trying to modify them. And, if I call for .RebuildTextures() after that, I crash Unity.
I am running Unity 3.5.5f3
Any idea ?
Answer by NicolasLIATTI · Sep 21, 2012 at 12:38 PM
Hi,
You should try this:
if (GUI.Button(new Rect(10,10,60,20), "256x256"))
{
ProceduralMaterial substance = renderer.sharedMaterial as ProceduralMaterial;
if (substance)
{
substance.SetProceduralVector("$outputsize", new Vector4(8.0f, 8.0f, 0.0f, 0.0f));
substance.RebuildTextures();
}
}
You also have to make sure that "Output Size" is checked when publishing. To enable this check box you must make the Substance material's output size relative to it's parent (not absolute).