Hello, In my application I receive materials info by network then I need to create a material with it. so far I create the material in the code bu I have no Idea about how to add roughness texture + intensity, metalness texure + intensity, normal map …
here is the code that I wrote create the material.
struct MaterialMetha
{
bool side;
bool transparent;
float opacity;
FString map;
FColor color;
FString roughnessMap;
float roughness;
FString metalnessMap ;
float metalness;
FString emissiveMap;
FColor emissive;
float emissiveIntensity;
FString normalMap;
};
bool AShapeGenerator::GenerateMaterial(FString id, MaterialMetha metha)
{
FString name = FString(TEXT("Material_")) + id;
FString path = FString(TEXT("/Game/Material/Generated/"));
FString packageName = path + name;
UPackage * package = CreatePackage(*packageName);
UMaterial* mat = NewObject<UMaterial>(package, FName(*name), RF_Public | RF_Standalone);
mat->AddToRoot();
#if WITH_EDITOR
mat->PreEditChange(nullptr);
mat->PostEditChange();
#endif
FAssetRegistryModule::AssetCreated(mat);
package->FullyLoad();
package->SetDirtyFlag(true);
//mat->Set
return true;
}
when I send the material by network It will appear with unreal default value on the editor, what I want to do is fill it with the value from MaterialMetha structure.
Thanks for you time.