Author Topic: GetGeneratedTextures() returns empty list  (Read 1407 times)

What's the trick to getting GetGeneratedTextures() to work? Here's my code:

Code: [Select]
myGraph.QueueForRender();
Substance.Game.Substance.RenderSubstancesSync();

var textures = myGraph.GetGeneratedTextures();
Debug.Log($"{textures.Count} textures");

Despite the graph having outputs that I can see in the inspector, GetGeneratedTextures() always returns 0 items. Am I not using it correctly?

What's the trick to getting GetGeneratedTextures() to work? Here's my code:

Code: [Select]
myGraph.QueueForRender();
Substance.Game.Substance.RenderSubstancesSync();

var textures = myGraph.GetGeneratedTextures();
Debug.Log($"{textures.Count} textures");

Despite the graph having outputs that I can see in the inspector, GetGeneratedTextures() always returns 0 items. Am I not using it correctly?

Hey @dgoyette ,

Is your Substance graph loaded in the scene or directly referenced in a script?
Last Edit: November 28, 2018, 11:22:10 pm

Both, actually.

I'm using HDRP, which means I can't directly use the Material that the Substance Plugin generates at this time. So instead, I've created a separate HDRP material, and dragged the Substance's generated textures into the textures of the Material. So I'm not sure whether that alone counts as using the substance directly in the scene?

At the same time, I also have a script in my scene that has a reference to the substance graph, and it's against that reference that I'm executing methods like SetInputString and GetGeneratedTextures(). You can see a screenshot of my script usage, and I've just attached the script as well.

Every once in a while, I've see GetGeneratedTextures return my textures, but usually it returns an empty list. I haven't nailed down what causes it to occasionally return the textures, though. But you can also see from my other post (https://forum.allegorithmic.com/index.php/topic,26597.0.html) that calling these methods is resulting in lots of full Unity crashes, so diagnosing this in depth is fairly slow and painful.


I've created a test project to demonstrate this behavior. (https://www.dropbox.com/s/qgfu5c78cfooqvz/SubstanceCrasher.zip?dl=0) It's a standard Unity 2018.2 project. Open "CrashScene", and you'll find a cube that has a script "ChangeFontSizeAndText". Pressing "J" runs the following code. The important detail is the last line, where I'm trying to get the generated textures, but every time I run that line it returns 0 textures.

Code: [Select]
    public void ChangeSubstance()
    {
        Debug.Log("Changing Substance");

        Graph.ResetGeneratedTextures();
        Graph.RefreshCurrentTarget();

        Graph.SetInputFloat("FontSize", UnityEngine.Random.Range(0.2f, 0.4f));
        Graph.SetInputString("Text", UnityEngine.Random.Range(0, 100).ToString());

        Graph.QueueForRender();
        Substance.Game.Substance.RenderSubstancesSync();

        Debug.Log($"Has {Graph.GetGeneratedTextures().Count} textures");
    }

I've created a test project to demonstrate this behavior. (https://www.dropbox.com/s/qgfu5c78cfooqvz/SubstanceCrasher.zip?dl=0) It's a standard Unity 2018.2 project. Open "CrashScene", and you'll find a cube that has a script "ChangeFontSizeAndText". Pressing "J" runs the following code. The important detail is the last line, where I'm trying to get the generated textures, but every time I run that line it returns 0 textures.

Code: [Select]
    public void ChangeSubstance()
    {
        Debug.Log("Changing Substance");

        Graph.ResetGeneratedTextures();
        Graph.RefreshCurrentTarget();

        Graph.SetInputFloat("FontSize", UnityEngine.Random.Range(0.2f, 0.4f));
        Graph.SetInputString("Text", UnityEngine.Random.Range(0, 100).ToString());

        Graph.QueueForRender();
        Substance.Game.Substance.RenderSubstancesSync();

        Debug.Log($"Has {Graph.GetGeneratedTextures().Count} textures");
    }

Thanks for supplying us with this repro project. I am asking the devs to take a look.

Cheers,
Wes
Head of Substance Demo Art Team
the3dninja@adobe.com
Twitter: The3DNinja