Author Topic: Runtime Generated Substance Textures have the same path name  (Read 1063 times)

Aim:
I am trying to create multiple dynamic materials in a level with different Substance graphs that you can edit at runtime.
Problem:
It seems that the lastest Substance rendered textures are saving with the same path name and file name i.e. basecolor etc, which is referenced by all previous dynamic materials.
Possible solution:
Add prefix to the files generated, ie. SMID_02_basecolor

What I have:
Created Graph instance from a substance factory
      add to an array.
Created a dynamic material instance
      add to an array.
Set parameters of Substance Graph.
Sync Rendering
Applied Textures to Dynamic Material.

This works well if you only have one Substance Instance.

I'm also not able to get a reference to the dynamic material I can only get a copy.

More information:
Here is a printout of a log file extracting parameter information, as you can see the Substance Textures generated are not unique. In the Editor when creating an instance from the Factory, Texture files are generated automatically with the instance name and the texture name appended. I have tried many variations of the tutorials with no avail.

Log file:
LogBlueprintUserMessages: [GI_IR_Learning_C_5]
Substance Instance Name:  SMID_335_ceramic_chamfered_tiles
Graph Instance Display Name: SMID_335_ceramic_chamfered_tiles
Dynamic Material ID:  335
Substance Instance  ID:  250
Texture Name:  baseColor
Texture Object Name:  baseColor
Texture Path:  /Engine/Transient.UnrealEdEngine_0:GI_IR_Learning_C_5.baseColor

LogBlueprintUserMessages: [GI_IR_Learning_C_5]
Substance Instance Name:  SMID_336_moon_orchid_petals
Graph Instance Display Name: SMID_336_moon_orchid_petals
Dynamic Material ID:  336
Substance Instance  ID:  211
Texture Name:  baseColor
Texture Object Name:  baseColor
Texture Path:  /Engine/Transient.UnrealEdEngine_0:GI_IR_Learning_C_5.baseColor

I was hoping that the 4.24 version would help, still no luck.
Tried Duplicating the instance get this now, still no unique texture names.
I hope someone can help soon, I suppose everyone in on holidays. Merry Christmas and happy new year all.

[GI_IR_Learning_C_14]
Substance Instance Name:  SMID_335_ceramic_chamfered_tiles
Graph Instance Display Name: SubstanceGraphInstance_0
Dynamic Material ID:  335
Substance Instance  ID:  250
Texture Name:  baseColor
Texture Object Name:  baseColor
Texture Path:  /Engine/Transient.UnrealEdEngine_0:GI_IR_Learning_C_14.baseColor

[GI_IR_Learning_C_14]
Substance Instance Name:  SMID_336_moon_orchid_petals
Graph Instance Display Name: SubstanceGraphInstance_1
Dynamic Material ID:  336
Substance Instance  ID:  211
Texture Name:  baseColor
Texture Object Name:  baseColor
Texture Path:  /Engine/Transient.UnrealEdEngine_0:GI_IR_Learning_C_14.baseColor


So looking forward to the answer to this question.
This is the first time I have asked a question in a forum, I have always worked it out my self. I had no idea it takes a while for a response.
Anyway happy new year all,

Darren Winfield

Found the answer, this post has the C++ code to rename the files all works now.
https://forum.substance3d.com/index.php?topic=29153.0

We modified the code slightly to the below, as we couldn't figure out how to include the SubstanceUtility.h file, stills works fine though.

Header file

Code: [Select]
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "IR_CPPFL.generated.h"

UCLASS()
class IR_LEARNING_API UIR_CPPFL : public UBlueprintFunctionLibrary
{
GENERATED_BODY()

UFUNCTION(BlueprintCallable, Category = "Substance", meta = (WorldContext = "WorldContextObject", DisplayName = "Rename Substance Texture", Keywords = "Texture Rename Substance"))
static void RenameSubstanceTexture(UObject* SubstanceTexture, FString NewName);
};

CPP FIle

Code: [Select]
#include "CPPFL.h"

void UCPPFL::RenameSubstanceTexture(UObject* SubstanceTexture, FString NewName)
{
if (!SubstanceTexture) return;
SubstanceTexture->Rename(*NewName, NULL, REN_ForceNoResetLoaders);
}

Here is the final add Dynamic Material Blueprint, The Update Blueprint is similar.