Automating Material Creation in Unreal Engine using Specific Texture Sets

Hello everyone,

I’m currently designing material packs for the Unreal Engine Marketplace. My folder structure is organized as follows:

Content>PackedName>Map, Material, Texture

What I want to achieve is to automate the creation of materials in Unreal Engine. Specifically, I would like a script or tool that can automatically find specific textures in the “Texture” folder (e.g., T_Metal_Base_01, T_Metal_AO_01, T_Metal_Normal_01, T_Metal_Spec_01, T_Metal_Roughness_01, T_Metal_Height_01), and place them into the corresponding slots in the material, creating and saving the material automatically.

For example, for a given set of textures, I want the script to find:

  • T_Metal_Base_01 → Base Color
  • T_Metal_AO_01 → Ambient Occlusion
  • T_Metal_Normal_01 → Normal
  • T_Metal_Spec_01 → Specular
  • T_Metal_Roughness_01 → Roughness
  • T_Metal_Height_01 → Height Map

And then save the newly created material instance in the appropriate folder.

I asked ChatGPT about this, and it suggested using the following Python script to achieve this:

import unreal

def create_material(material_name, base, ao, normal, spec, roughness, height):
    material_path = f"/Game/YourPackageName/Material/{material_name}"
    
    # Create Material
    material_instance = unreal.AssetToolsHelpers.get_asset_tools().create_asset(
        material_name, "/Game/YourPackageName/Material", unreal.MaterialInstanceConstant, unreal.MaterialFactoryNew()
    )
    
    # Assign Textures
    unreal.MaterialEditingLibrary.set_material_instance_texture_parameter_value(material_instance, "BaseColor", base)
    unreal.MaterialEditingLibrary.set_material_instance_texture_parameter_value(material_instance, "AO", ao)
    unreal.MaterialEditingLibrary.set_material_instance_texture_parameter_value(material_instance, "Normal", normal)
    unreal.MaterialEditingLibrary.set_material_instance_texture_parameter_value(material_instance, "Specular", spec)
    unreal.MaterialEditingLibrary.set_material_instance_texture_parameter_value(material_instance, "Roughness", roughness)
    unreal.MaterialEditingLibrary.set_material_instance_texture_parameter_value(material_instance, "Height", height)

    # Save Material
    unreal.EditorAssetLibrary.save_asset(material_path, only_if_is_dirty=False)

# Example call:
create_material("T_Metal_01", "/Game/YourPackageName/Texture/T_Metal_Base_01", ...)

However, I don’t have much experience with Blueprint or Python. I’ve tried, but I haven’t been successful in creating something like this myself. Is it possible to develop a material generator like this, and if so, could someone point me in the right direction or provide additional guidance?

Thank you in advance for your help!

I’ve been waiting for Unreal to automate this process for years, did you have any luck finding/creating a script to automate import ?