Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - Gilles Boulard 0

Pages: [1]

substance api is not really helpful : not up to date (api refers to 2.2 when plugin is 2.5), and almost no info on public functions, not even a comment in the code above functions.

we are using substance to generate lots of random different textures from like maybe 50+ SubstanceGraph.
we would like to have a random texture each time we launch the app or on demand during a loading for example. but we don't need to make the txture chage after it, so apparently we don't need to keep the SubstanceGraph.

Currently the "Total System Memory Usage" is sky rocketting (each substance graph is generating 3 1024² textures : albedo, normal, metallic).

What would be the script to keep only the material and textures once the generation has been done. Would it be enough to solve our memory problem ?

we've tried the Substance.Free(string assetPath) after we copied the material, but textures seems to be destroyed.
maybe keep a ref on textures with GetGeneratedTextures ?

any help aprreciated


we get this error very often but not always...
this can happen in editor or at runtime. when in unity editor we have to quit and relaunch unity.

Code: [Select]
NullReferenceException: Object reference not set to an instance of an object.
  at Substance.Game.SubstanceGraph.OnEnable () [0x00000] in <00000000000000000000000000000000>:0
  at UnityEngine.ScriptableObject.CreateInstance[T] () [0x00000] in <00000000000000000000000000000000>:0
  at Substance.Game.SubstanceGraph.CreateGraphInstance (Substance.Game.Substance parent, System.UInt32 descIndex, System.UInt32 instanceIndex, System.String packageURL, System.String graphLabel, System.String prototypeName, System.String description, System.String category, System.String keywords, System.String author, System.String authorURL, System.String userTag) [0x00000] in <00000000000000000000000000000000>:0
  at Substance.Game.SubstanceGraph.DuplicateInstance (Substance.Game.SubstanceGraph graph, System.String pNewGraphName) [0x00000] in <00000000000000000000000000000000>:0
  at Substance.Game.SubstanceGraph.Duplicate (Substance.Game.SubstanceGraph graph1, System.String pNewGraphName) [0x00000] in <00000000000000000000000000000000>:0

sometimes this error comes instead:
Code: [Select]
NullReferenceException: Object reference not set to an instance of an object
Substance.Game.SubstanceGraph.GetUniqueGraphName (Substance.Game.Substance substance, System.String prototypeName) (at <686b229c4bb54a199af4ea1b7d9b3fc4>:0)
Substance.Game.SubstanceGraph.DuplicateInstance (Substance.Game.SubstanceGraph graph, System.String pNewGraphName) (at <686b229c4bb54a199af4ea1b7d9b3fc4>:0)
Substance.Game.SubstanceGraph.Duplicate (Substance.Game.SubstanceGraph graph1, System.String pNewGraphName) (at <686b229c4bb54a199af4ea1b7d9b3fc4>:0)
Substance.Game.SubstanceGraph.Duplicate (Substance.Game.SubstanceGraph graph1) (at <686b229c4bb54a199af4ea1b7d9b3fc4>:0)
Substance.Game.SubstanceGraph.Duplicate () (at <686b229c4bb54a199af4ea1b7d9b3fc4>:0)

we don't do anything special.
loading the substance graph from an assetbundle (at runtime) or as a referenced asset (in editor)
trying to duplicate it to change the randomseed and use the new material.

this is done in a loop with async rendering in parallel, could it be a problem (both rendering and duplicate - maybe some concurrent access in threads?)
Code: [Select]
for (int i = 0; i < nb; i++)

// clone substance graph
sgClone = substanceRef.Duplicate();

sgClone.SetInputFloat("$randomseed", Random.Range(0, 1 << 8));
// render substance graph
_RandomizeSubstancesData.Add(new SubstanceData(new Material(sgClone.material), refid));

Pages: [1]