Material Importer/Converter

https://help.poliigon.com/en/articles/2540839-poliigon-material-converter-addon-for-blender something akin to this would be awesome to have. I’m in rhino, but I’m sure most of the applications would benefit from this.

Thanks, I can file this as a feature request. Could you also let me know about the specific use case for this in your scenario, so that I can also add it as further feedback? :slight_smile:

Sure, it’s mostly related to improving the speed at which we can add new materials into a file. If there was a “+” within the Material Editor:

Or just a command for this, if the importer could then import all the image textures related to the material into the appropriate slots, it would make it quite a bit faster to load in new materials. Something as impressive as the Poliigon importer would be nice, but the main functionality, for me at least, would be to be able to select just the diffuse channel image and then automatically import all other maps.

A demo of the Poliigon one is here.

A bit of development for rhino users: Here’s a script from Willem Derks from this thread. I added some adjustments so that it creates a enscape capable material including roughness map in the environment slot. NOTE: This script requires that each material is placed in it’s own folder, I’ll be doing some adjustments in the future so that it can find a map based on the file name instead.

import rhinoscriptsyntax as rs
import scriptcontext as sc
import os
import fnmatch

def findTexture(name, path):
    for file in os.listdir(path):
        if fnmatch.fnmatch(file, name):
            return os.path.join(path,file)

def make_material_by_diffuse():
    
    
    diffuse_file = rs.OpenFileName('get diffuse texture')
    print 'diffuse_file :',diffuse_file
    
    texture_path = os.path.dirname(diffuse_file)
    print 'texture_path :',texture_path
    
    diffuse_name = os.path.basename(diffuse_file)
    #assuming a bump.png file present alongside the diffuse texture file
    bump_file = findTexture("*nrm*", texture_path)
    print(bump_file)
    environment_file = findTexture("*rgh*", texture_path)
    print(environment_file)
    
    
    new_material_index = sc.doc.Materials.Add()
    print new_material_index
    material_table = sc.doc.Materials
    new_material = material_table.FindIndex(new_material_index)
    new_material.Name = diffuse_name + " glossyenvironment"
    
    new_material.SetBitmapTexture(diffuse_file)
    if os.path.isfile(bump_file):
        new_material.SetBumpTexture(bump_file)
        new_material.SetEnvironmentTexture(environment_file)
    
    new_material.CommitChanges()
    
    #I don't quickly see how to make sure the material is present in the library so I made the hack below:
    
    dummy_layer_name = diffuse_file
    if not rs.IsLayer(dummy_layer_name) : rs.AddLayer(dummy_layer_name)
    #dummy_layer_index = sc.doc.Layers.FindByFullPath(dummy_layer_name,True)
    dummy_layer = sc.doc.Layers.FindName(dummy_layer_name)
    dummy_layer.RenderMaterialIndex = new_material_index
    sc.doc.Views.Redraw()
    #rs.DeleteLayer(dummy_layer_name)
    
    
make_material_by_diffuse()