Skip to main content
ryangold333
Participant
Dec 27, 2023 12:54 PM UTC
Answered

Image to Material API

Hi all,

 

I was wondering if it's possible to script an Image to Material pipeline using the Command Line Tools/Automation Toolkit or the Sampler Python API?

 

Thanks,
Ryan

This topic is closed to new replies. Start a new post to keep the conversation going.
DanielMilleCorrect answer
Participant
Dec 29, 2023 1:25 AM UTC

Hello, @ryangold333 !
I had the same issue. You can write this functionin your script in pycharm and save it as the .py file. Then import to the Sampler Edit->Preferences-> Plugins and Scripts.

def image_to_material_batch(folder_path):
    for file in os.listdir(folder_path):
        #here you can define texture format to avoid importing unnecessary files
        if file.endswith(".png"):
            image_path_list = [os.path.join(folder_path, file)]
            asset_name = os.path.basename(file).split('.')[0]
            asset = ssa.create_asset(asset_name, ssa.material)
            asset.import_images(image_path_list, 0, ssa.image_to_material_AI_powered, False)

 

3 replies

Participant
Dec 29, 2023 1:28 AM UTC

Of course you will then need to run this function and define your directory. I used project file dir. After importing script to Sampler you just run it from the top menu and it should work.

Translate
ryangold333
Participant
Jan 2, 2024 10:43 AM UTC

Hey thanks so much! That's what I needed 🙂

Translate
DanielMilleCorrect answer
Participant
Dec 29, 2023 1:25 AM UTC

Hello, @ryangold333 !
I had the same issue. You can write this functionin your script in pycharm and save it as the .py file. Then import to the Sampler Edit->Preferences-> Plugins and Scripts.

def image_to_material_batch(folder_path):
    for file in os.listdir(folder_path):
        #here you can define texture format to avoid importing unnecessary files
        if file.endswith(".png"):
            image_path_list = [os.path.join(folder_path, file)]
            asset_name = os.path.basename(file).split('.')[0]
            asset = ssa.create_asset(asset_name, ssa.material)
            asset.import_images(image_path_list, 0, ssa.image_to_material_AI_powered, False)

 

Translate