Isotropix Forums

Megascans Surfaces to Clarisse

Clarisse Scripting related topics

Megascans Surfaces to Clarisse

Unread postby jandersunstar » Mon Mar 12, 2018 9:17 pm

Want to share with you the script I did for creating shaders using the Megascans Surfaces, all you need to do is open one of the textures from one of the surfaces folder, for example the file rmqlqfp_4K_Albedo.jpg that is inside the folder \Megascans\surfaces\Asphalt_Coarse_rmqlqfp0\

It will get the height and size from the json file that should be inside that folder, in this example the file is rmqlqfp0.json

I am using the triplanar projection so you don't have to worry about UVs.

Best,
Luis

Code: Select all
# This script creates a MaterialPhysicalStandard shader from a folder
# containing images comming from Megascans.
#
# It will get the info of the heigth and the scanned area from the json file
# that should be in the same file as the images. If the displacement is wrong
# you can change the size from the _HEIGHT_DIS node in the input 2. A value
# of 1 equals 1 meters.
#
# The size of the texture is define in the UV of each TextureMap, you can change
# the size modifying these values. 1.0x equals 1 meters.
#
# It won't assign the shader to a geometry.
#
# This script was made by modifying the ibl.py script provided by Clarisse.
#
# Luis Montemayor
#
#
from os import listdir
from os.path import isfile, join
import json


extensions = 'All Known Files...\t*.{exr,tif,tx,hdr,tga,png,jpg,jpeg,bmp,sgi,psd,pic}\n\
Open EXR \t*.{exr}\nTIFF \t*.{tif}\nTX \t*.{tx}\n\
HDR \t*.{hdr}\nTarga \t*.{tga}\nPNG \t*.{png}\nJPG \t*.{jpg}\n\
JPEG \t*.{jpeg}\nBMP \t*.{bmp}\nSGI \t*.{sgi}\nPSD \t*.{psd}\n\
PIC \t*.{pic}'
file = ix.api.GuiWidget.open_file(ix.application, '', 'Browse for an image', extensions)
if file != "":
    ix.begin_command_batch("Build Shader")
    path = file.split('/')
    path.pop(-1)
    folder_name = file.split('/').pop(-2)
    context = ix.cmds.CreateContext(folder_name)
    path =  "/".join(path)
    onlyfiles = [f for f in listdir(path) if isfile(join(path, f))]

    # Define Variables for empty textures
    txAlbedo = ''
    txRougness = ''
    txSpecular = ''
    txCavity = ''
    txNormal = ''
    txSpecular = ''
    txRougness = ''
    txGloss = ''
    txBump = ''
    txAlbedo = ''
    txAO = ''
    txDisplacement = ''

    # Define Variables for empty json file
    displacementHeight = '0'
    physicalSize = '1'
    data = '';
    for file in onlyfiles:
        if file.lower().endswith(('.png', '.jpg', '.jpeg', '.json', '.exr')):
            if '_Normal.' in file:
                normal_tx = path + '/' + file
                txNormal = ix.cmds.CreateObject(folder_name + '_Normal_tx', 'TextureMapFile', context)
                txNormal.attrs.filename = normal_tx
                txNormal.attrs.color_space_auto_detect = False
                txNormal.attrs.file_color_space = 'linear'
                txNormal.attrs.projection = '3'
                txNormal.attrs.object_space = '2'

            elif '_Specular.' in file:
                specular_tx = path + '/' + file
                txSpecular = ix.cmds.CreateObject(folder_name + '_Specular_tx', 'TextureMapFile', context)
                txSpecular.attrs.filename = specular_tx
                txSpecular.attrs.color_space_auto_detect = False
                txSpecular.attrs.file_color_space = 'sRGB'
                txSpecular.attrs.projection = '3'
                txSpecular.attrs.object_space = '2'

            elif '_Roughness.' in file:
                roughness_tx = path + '/' + file
                txRougness = ix.cmds.CreateObject(folder_name + '_Roughness_tx', 'TextureMapFile', context)
                txRougness.attrs.filename = roughness_tx
                txRougness.attrs.color_space_auto_detect = False
                txRougness.attrs.single_channel_file_behavior = 1
                txRougness.attrs.file_color_space = 'linear'
                txRougness.attrs.projection = '3'
                txRougness.attrs.object_space = '2'

            elif '_Gloss.' in file:
                gloss_tx = path + '/' + file
                txGloss = ix.cmds.CreateObject(folder_name + '_Gloss_tx', 'TextureMapFile', context)
                txGloss.attrs.filename = gloss_tx
                txGloss.attrs.color_space_auto_detect = False
                txGloss.attrs.single_channel_file_behavior = 1
                txGloss.attrs.file_color_space = 'linear'
                txGloss.attrs.projection = '3'
                txGloss.attrs.object_space = '2'

            elif '_Albedo.' in file:
                albedo_tx = path + '/' + file
                txAlbedo = ix.cmds.CreateObject(folder_name + '_Albedo_tx', 'TextureMapFile', context)
                txAlbedo.attrs.filename = albedo_tx
                txAlbedo.attrs.color_space_auto_detect = False
                txAlbedo.attrs.single_channel_file_behavior = 1
                txAlbedo.attrs.file_color_space = 'sRGB'
                txAlbedo.attrs.projection = '3'
                txAlbedo.attrs.object_space = '2'

            elif '_AO.' in file:
                ao_tx = path + '/' + file
                txAO = ix.cmds.CreateObject(folder_name + '_AO_tx', 'TextureMapFile', context)
                txAO.attrs.filename = ao_tx
                txAO.attrs.color_space_auto_detect = False
                txAO.attrs.single_channel_file_behavior = 1
                txAO.attrs.file_color_space = 'sRGB'
                txAO.attrs.projection = '3'
                txAO.attrs.object_space = '2'

            elif '_Bump.' in file:
                bump_tx = path + '/' + file
                txBump = ix.cmds.CreateObject(folder_name + '_Bump_tx', 'TextureMapFile', context)
                txBump.attrs.filename = bump_tx
                txBump.attrs.color_space_auto_detect = False
                txBump.attrs.single_channel_file_behavior = 1
                txBump.attrs.file_color_space = 'linear'
                txBump.attrs.projection = '3'
                txBump.attrs.object_space = '2'

            elif '_Cavity.' in file:
                cavity_tx = path + '/' + file
                txCavity = ix.cmds.CreateObject(folder_name + '_Cavity_tx', 'TextureMapFile', context)
                txCavity.attrs.filename = cavity_tx
                txCavity.attrs.color_space_auto_detect = False
                txCavity.attrs.single_channel_file_behavior = 1
                txCavity.attrs.file_color_space = 'sRGB'
                txCavity.attrs.projection = '3'
                txCavity.attrs.object_space = '2'

            elif '_Displacement.' in file:
                displacement_tx = path + '/' + file
                txDisplacement = ix.cmds.CreateObject(folder_name + '_Displacement_tx', 'TextureMapFile', context)
                txDisplacement.attrs.filename = displacement_tx
                txDisplacement.attrs.color_space_auto_detect = False
                txDisplacement.attrs.single_channel_file_behavior = 1
                txDisplacement.attrs.file_color_space = 'linear'
                txDisplacement.attrs.projection = '3'
                txDisplacement.attrs.object_space = '2'

            elif '.json' in file:
                with open(path + '/' + file) as json_data:
                    data = json.load(json_data)

    # Define Variables from json
    if data != "":
        displacementHeight = data['meta'][1]['value']
        displacementHeight = displacementHeight.split(' ')
        displacementHeight = float(displacementHeight[0])
        displacementHeight = str(displacementHeight)
        physicalSize = data['meta'][0]['value'].split('x')
        physicalSize = str(physicalSize[0])

    # Create Physical Shader and assgin the PINK color
    stand_mat = ix.cmds.CreateObject(folder_name + '_SHD', 'MaterialPhysicalStandard', context)
    ix.cmds.ColorTagItems([stand_mat.get_full_name()], "pink")

    if txAlbedo != "":
        triALB = ix.cmds.CreateObject(folder_name + '_TRI_ALB', "TextureTriplanar", "", context)
        ix.cmds.SetValues([triALB.get_full_name() + ".blend"], ["0.5"])
        ix.cmds.SetValues([triALB.get_full_name() + ".object_space"], ["2"])
        ix.cmds.SetTexture([triALB.get_full_name() + ".right"], txAlbedo.get_full_name())
        ix.cmds.SetTexture([triALB.get_full_name() + ".left"], txAlbedo.get_full_name())
        ix.cmds.SetTexture([triALB.get_full_name() + ".top"], txAlbedo.get_full_name())
        ix.cmds.SetTexture([triALB.get_full_name() + ".bottom"], txAlbedo.get_full_name())
        ix.cmds.SetTexture([triALB.get_full_name() + ".front"], txAlbedo.get_full_name())
        ix.cmds.SetTexture([triALB.get_full_name() + ".back"], txAlbedo.get_full_name())
        ix.cmds.SetTexture([stand_mat.get_full_name() + ".diffuse_front_color"], triALB.get_full_name())
        ix.cmds.SetValues([txAlbedo.get_full_name() + ".uv_scale[0]"], [physicalSize])
        ix.cmds.SetValues([txAlbedo.get_full_name() + ".uv_scale[1]"], [physicalSize])
        ix.cmds.SetValues([txAlbedo.get_full_name() + ".uv_scale[2]"], [physicalSize])

    if txSpecular != "":
        triSPC = ix.cmds.CreateObject(folder_name + '_TRI_SPC', "TextureTriplanar", "", context)
        ix.cmds.SetValues([triSPC.get_full_name() + ".blend"], ["0.5"])
        ix.cmds.SetValues([triSPC.get_full_name() + ".object_space"], ["2"])
        ix.cmds.SetTexture([triSPC.get_full_name() + ".right"], txSpecular.get_full_name())
        ix.cmds.SetTexture([triSPC.get_full_name() + ".left"], txSpecular.get_full_name())
        ix.cmds.SetTexture([triSPC.get_full_name() + ".top"], txSpecular.get_full_name())
        ix.cmds.SetTexture([triSPC.get_full_name() + ".bottom"], txSpecular.get_full_name())
        ix.cmds.SetTexture([triSPC.get_full_name() + ".front"], txSpecular.get_full_name())
        ix.cmds.SetTexture([triSPC.get_full_name() + ".back"], txSpecular.get_full_name())
        ix.cmds.SetTexture([stand_mat.get_full_name() + ".specular_1_color"], triSPC.get_full_name())
        ix.cmds.SetValues([txSpecular.get_full_name() + ".uv_scale[0]"], [physicalSize])
        ix.cmds.SetValues([txSpecular.get_full_name() + ".uv_scale[1]"], [physicalSize])
        ix.cmds.SetValues([txSpecular.get_full_name() + ".uv_scale[2]"], [physicalSize])

    if txRougness != "":
        triROU = ix.cmds.CreateObject(folder_name + '_TRI_ROU', "TextureTriplanar", "", context)
        ix.cmds.SetValues([triROU.get_full_name() + ".blend"], ["0.5"])
        ix.cmds.SetValues([triROU.get_full_name() + ".object_space"], ["2"])
        ix.cmds.SetTexture([triROU.get_full_name() + ".right"], txRougness.get_full_name())
        ix.cmds.SetTexture([triROU.get_full_name() + ".left"], txRougness.get_full_name())
        ix.cmds.SetTexture([triROU.get_full_name() + ".top"], txRougness.get_full_name())
        ix.cmds.SetTexture([triROU.get_full_name() + ".bottom"], txRougness.get_full_name())
        ix.cmds.SetTexture([triROU.get_full_name() + ".front"], txRougness.get_full_name())
        ix.cmds.SetTexture([triROU.get_full_name() + ".back"], txRougness.get_full_name())
        ix.cmds.SetTexture([stand_mat.get_full_name() + ".specular_1_roughness"], triROU.get_full_name())
        ix.cmds.SetValues([txRougness.get_full_name() + ".uv_scale[0]"], [physicalSize])
        ix.cmds.SetValues([txRougness.get_full_name() + ".uv_scale[1]"], [physicalSize])
        ix.cmds.SetValues([txRougness.get_full_name() + ".uv_scale[2]"], [physicalSize])

    if txBump != "":
        triBMP = ix.cmds.CreateObject(folder_name + '_TRI_BMP', "TextureTriplanar", "", context)
        ix.cmds.SetValues([triBMP.get_full_name() + ".blend"], ["0.5"])
        ix.cmds.SetValues([triBMP.get_full_name() + ".object_space"], ["2"])
        ix.cmds.SetTexture([triBMP.get_full_name() + ".right"], txBump.get_full_name())
        ix.cmds.SetTexture([triBMP.get_full_name() + ".left"], txBump.get_full_name())
        ix.cmds.SetTexture([triBMP.get_full_name() + ".top"], txBump.get_full_name())
        ix.cmds.SetTexture([triBMP.get_full_name() + ".bottom"], txBump.get_full_name())
        ix.cmds.SetTexture([triBMP.get_full_name() + ".front"], txBump.get_full_name())
        ix.cmds.SetTexture([triBMP.get_full_name() + ".back"], txBump.get_full_name())
        txBP = ix.cmds.CreateObject(folder_name + '_BMP', "TextureBumpMap", "", context)
        ix.cmds.SetValues([txBP.get_full_name() + ".input"], [displacementHeight])
        ix.cmds.SetTexture([stand_mat.get_full_name() + ".normal_input"], txBP.get_full_name())
        ix.cmds.SetTexture([txBP.get_full_name() + ".input"], triBMP.get_full_name())
        ix.cmds.SetValues([txBump.get_full_name() + ".uv_scale[0]"], [physicalSize])
        ix.cmds.SetValues([txBump.get_full_name() + ".uv_scale[1]"], [physicalSize])
        ix.cmds.SetValues([txBump.get_full_name() + ".uv_scale[2]"], [physicalSize])

    # If there is a Normal Map then use this instead of the Bump
    if txNormal != "":
        triNOR = ix.cmds.CreateObject(folder_name + '_TRI_NOR', "TextureTriplanar", "", context)
        ix.cmds.SetValues([triNOR.get_full_name() + ".blend"], ["0.5"])
        ix.cmds.SetValues([triNOR.get_full_name() + ".object_space"], ["2"])
        ix.cmds.SetTexture([triNOR.get_full_name() + ".right"], txNormal.get_full_name())
        ix.cmds.SetTexture([triNOR.get_full_name() + ".left"], txNormal.get_full_name())
        ix.cmds.SetTexture([triNOR.get_full_name() + ".top"], txNormal.get_full_name())
        ix.cmds.SetTexture([triNOR.get_full_name() + ".bottom"], txNormal.get_full_name())
        ix.cmds.SetTexture([triNOR.get_full_name() + ".front"], txNormal.get_full_name())
        ix.cmds.SetTexture([triNOR.get_full_name() + ".back"], txNormal.get_full_name())
        txNM = ix.cmds.CreateObject(folder_name + '_NOR', "TextureNormalMap", "", context)
        ix.cmds.SetTexture([stand_mat.get_full_name() + ".normal_input"], txNM.get_full_name())
        ix.cmds.SetTexture([txNM.get_full_name() + ".input"], triNOR.get_full_name())
        ix.cmds.SetValues([txNormal.get_full_name() + ".uv_scale[0]"], [physicalSize])
        ix.cmds.SetValues([txNormal.get_full_name() + ".uv_scale[1]"], [physicalSize])
        ix.cmds.SetValues([txNormal.get_full_name() + ".uv_scale[2]"], [physicalSize])

    # Create Displacement Shader and assgin the PINK color
    if txDisplacement != "":
        triDIS = ix.cmds.CreateObject(folder_name + '_TRI_DIS', "TextureTriplanar", "", context)
        ix.cmds.SetValues([triDIS.get_full_name() + ".blend"], ["0.5"])
        ix.cmds.SetValues([triDIS.get_full_name() + ".object_space"], ["2"])
        ix.cmds.SetTexture([triDIS.get_full_name() + ".right"], txDisplacement.get_full_name())
        ix.cmds.SetTexture([triDIS.get_full_name() + ".left"], txDisplacement.get_full_name())
        ix.cmds.SetTexture([triDIS.get_full_name() + ".top"], txDisplacement.get_full_name())
        ix.cmds.SetTexture([triDIS.get_full_name() + ".bottom"], txDisplacement.get_full_name())
        ix.cmds.SetTexture([triDIS.get_full_name() + ".front"], txDisplacement.get_full_name())
        ix.cmds.SetTexture([triDIS.get_full_name() + ".back"], txDisplacement.get_full_name())
        heiDIS = ix.cmds.CreateObject(folder_name + '_HEIGHT_DIS', "TextureMultiply", "", context)
        ix.cmds.SetTexture([heiDIS.get_full_name() + ".input1"], triDIS.get_full_name())
        print displacementHeight
        ix.cmds.SetValues([heiDIS.get_full_name() + ".input2"], [displacementHeight, displacementHeight, displacementHeight])
        displacement = ix.cmds.CreateObject(folder_name + '_DIS', "Displacement", context)
        ix.cmds.SetTexture([displacement.get_full_name() + ".front_value"], heiDIS.get_full_name())
        ix.cmds.SetValues([displacement.get_full_name() + ".front_value"], ["1"])
        ix.cmds.SetValues([displacement.get_full_name() + ".bound[0]"], [displacementHeight])
        ix.cmds.SetValues([displacement.get_full_name() + ".bound[1]"], [displacementHeight])
        ix.cmds.SetValues([displacement.get_full_name() + ".bound[2]"], [displacementHeight])
        ix.cmds.SetValues([txDisplacement.get_full_name() + ".uv_scale[0]"], [physicalSize])
        ix.cmds.SetValues([txDisplacement.get_full_name() + ".uv_scale[1]"], [physicalSize])
        ix.cmds.SetValues([txDisplacement.get_full_name() + ".uv_scale[2]"], [physicalSize])
        ix.cmds.SetValues([txDisplacement.get_full_name() + ".uv_scale[2]"], [physicalSize])
        ix.cmds.ColorTagItems([displacement.get_full_name()], "pink")

    if txGloss != "":
        triGLOS = ix.cmds.CreateObject(folder_name + '_TRI_GLOS', "TextureTriplanar", "", context)
        ix.cmds.SetValues([triGLOS.get_full_name() + ".blend"], ["0.5"])
        ix.cmds.SetValues([triGLOS.get_full_name() + ".object_space"], ["2"])
        ix.cmds.SetTexture([triGLOS.get_full_name() + ".right"], txGloss.get_full_name())
        ix.cmds.SetTexture([triGLOS.get_full_name() + ".left"], txGloss.get_full_name())
        ix.cmds.SetTexture([triGLOS.get_full_name() + ".top"], txGloss.get_full_name())
        ix.cmds.SetTexture([triGLOS.get_full_name() + ".bottom"], txGloss.get_full_name())
        ix.cmds.SetTexture([triGLOS.get_full_name() + ".front"], txGloss.get_full_name())
        ix.cmds.SetTexture([triGLOS.get_full_name() + ".back"], txGloss.get_full_name())
        ix.cmds.SetTexture([stand_mat.get_full_name() + ".specular_1_color"], triGLOS.get_full_name())
        ix.cmds.SetValues([txGloss.get_full_name() + ".uv_scale[0]"], [physicalSize])
        ix.cmds.SetValues([txGloss.get_full_name() + ".uv_scale[1]"], [physicalSize])
        ix.cmds.SetValues([txGloss.get_full_name() + ".uv_scale[2]"], [physicalSize])


    if txAO != "":
        triAO = ix.cmds.CreateObject(folder_name + '_TRI_AO', "TextureTriplanar", "", context)
        ix.cmds.SetValues([triAO.get_full_name() + ".blend"], ["0.5"])
        ix.cmds.SetValues([triAO.get_full_name() + ".object_space"], ["2"])
        ix.cmds.SetTexture([triAO.get_full_name() + ".right"], txAO.get_full_name())
        ix.cmds.SetTexture([triAO.get_full_name() + ".left"], txAO.get_full_name())
        ix.cmds.SetTexture([triAO.get_full_name() + ".top"], txAO.get_full_name())
        ix.cmds.SetTexture([triAO.get_full_name() + ".bottom"], txAO.get_full_name())
        ix.cmds.SetTexture([triAO.get_full_name() + ".front"], txAO.get_full_name())
        ix.cmds.SetTexture([triAO.get_full_name() + ".back"], txAO.get_full_name())
        txAO_MUL = ix.cmds.CreateObject(folder_name + '_MUL_AO', "TextureMultiply", "", context)
        ix.cmds.SetTexture([txAO_MUL.get_full_name() + ".input2"], triAO.get_full_name())
        ix.cmds.SetTexture([txAO_MUL.get_full_name() + ".input1"], triALB.get_full_name())
        ix.cmds.SetTexture([stand_mat.get_full_name() + ".diffuse_front_color"], txAO_MUL.get_full_name())
        ix.cmds.SetValues([txAO.get_full_name() + ".uv_scale[0]"], [physicalSize])
        ix.cmds.SetValues([txAO.get_full_name() + ".uv_scale[1]"], [physicalSize])
        ix.cmds.SetValues([txAO.get_full_name() + ".uv_scale[2]"], [physicalSize])

    if txCavity != "":
        triCAV = ix.cmds.CreateObject(folder_name + '_TRI_CAV', "TextureTriplanar", "", context)
        ix.cmds.SetValues([triCAV.get_full_name() + ".blend"], ["0.5"])
        ix.cmds.SetValues([triCAV.get_full_name() + ".object_space"], ["2"])
        ix.cmds.SetTexture([triCAV.get_full_name() + ".right"], txCavity.get_full_name())
        ix.cmds.SetTexture([triCAV.get_full_name() + ".left"], txCavity.get_full_name())
        ix.cmds.SetTexture([triCAV.get_full_name() + ".top"], txCavity.get_full_name())
        ix.cmds.SetTexture([triCAV.get_full_name() + ".bottom"], txCavity.get_full_name())
        ix.cmds.SetTexture([triCAV.get_full_name() + ".front"], txCavity.get_full_name())
        ix.cmds.SetTexture([triCAV.get_full_name() + ".back"], txCavity.get_full_name())
        txCAV_MUL = ix.cmds.CreateObject(folder_name + '_MUL_CAV', "TextureMultiply", "", context)
        txCAV_RES_MUL = ix.cmds.CreateObject(folder_name + '_RES_CAV_MUL', "TextureRescale", "", context)
        ix.cmds.SetTexture([txCAV_RES_MUL.get_full_name() + ".input"], triCAV.get_full_name())
        ix.cmds.SetValues([txCAV_RES_MUL.get_full_name() + ".input_max"], ["0.5", "0.5", "0.5"])
        ix.cmds.SetTexture([txCAV_MUL.get_full_name() + ".input2"], txCAV_RES_MUL.get_full_name())
        ix.cmds.SetTexture([txCAV_MUL.get_full_name() + ".input1"], txAO_MUL.get_full_name())       
        ix.cmds.SetTexture([stand_mat.get_full_name() + ".diffuse_front_color"], txCAV_MUL.get_full_name())
        ix.cmds.SetValues([txCavity.get_full_name() + ".uv_scale[0]"], [physicalSize])
        ix.cmds.SetValues([txCavity.get_full_name() + ".uv_scale[1]"], [physicalSize])
        ix.cmds.SetValues([txCavity.get_full_name() + ".uv_scale[2]"], [physicalSize])
    ix.end_command_batch()



else:
    ix.log_warning('This script has been aborted.')
User avatar
jandersunstar
 
Posts: 252
Joined: Fri Jun 06, 2014 9:21 pm
Location: Mexico City

Re: Megascans Surfaces to Clarisse

Unread postby jandersunstar » Mon Mar 12, 2018 9:44 pm

MegascansToClarisse_v1.jpg
some examples
MegascansToClarisse_v2.jpg
some examples
MegascansToClarisse_v3.jpg
some examples
User avatar
jandersunstar
 
Posts: 252
Joined: Fri Jun 06, 2014 9:21 pm
Location: Mexico City

Re: Megascans Surfaces to Clarisse

Unread postby jandersunstar » Mon Mar 12, 2018 10:25 pm

To blend two shaders/displacements just create a MaterialPhysicalBlend, connect your first shader into input 1 and the second into input 2, for the displacement create a new displacement, set the height to 1, and then connect the front value to a TextureBlend, and in this TextureBlend connect into input 1 the Height_DIS of your first shader, and the Height_DIS of your second shader into input 2. Then you can connect a texture or a scope into the mix of the TextureBlend and MaterialPhysicalBlend.

MegascansToClarisse_BLEND_v1.jpg
Example.

MegascansToClarisse_BLEND_v2.jpg
Tree.
User avatar
jandersunstar
 
Posts: 252
Joined: Fri Jun 06, 2014 9:21 pm
Location: Mexico City

Re: Megascans Surfaces to Clarisse

Unread postby David_A » Tue Mar 13, 2018 8:46 am

Thank you very much Luis!!
David_A
 
Posts: 131
Joined: Wed Apr 06, 2016 11:24 am

Re: Megascans Surfaces to Clarisse

Unread postby dboude » Tue Mar 13, 2018 11:12 am

Thanks for sharing Luis. It works, however it uses the glossy map to drive the specular color. I guess it might be more accurate using the specular map to drive the specular color, isn't it ?

Cheers ;)
Démian
Isotropix
Technical Artist - Clarisse Specialist
User avatar
dboude
 
Posts: 518
Joined: Mon Jul 03, 2017 11:51 am

Re: Megascans Surfaces to Clarisse

Unread postby sam » Tue Mar 13, 2018 3:26 pm

Great stuff. You know Luis instead of the scope you could use a point cloud texture so you could actually paint where you want.
Sam Assadian
Isotropix
CEO/Founder
User avatar
sam
 
Posts: 1125
Joined: Sat Jan 26, 2013 12:33 am

Re: Megascans Surfaces to Clarisse

Unread postby jandersunstar » Tue Mar 13, 2018 5:12 pm

Im going to try with the point cloud texture Sam :)

I did some tests with the Specular Demian, but the map doesn't look right, It seems like the colors are inverted, but if you invert them it doesn't work, then I tried with the Gloss map and everything worked just fine. I don't know if there is a document where it says which map should be used with Clarisse shaders. Could you do some tests and tell me if the specular map is the one I should use?

glossvsspecular.jpg
You can see that I get the right reflection of the water on the mud using the Gloss map.


-Luis
User avatar
jandersunstar
 
Posts: 252
Joined: Fri Jun 06, 2014 9:21 pm
Location: Mexico City

Re: Megascans Surfaces to Clarisse

Unread postby dboude » Thu Mar 15, 2018 12:07 pm

Hi Luis,

I made some tests and I find the material more accurate with the specular map. However, the file color space of the specular map has to be set to linear. (I made the tests only on the two free scans you can download from Megascan).

Another thing, It would be great to make all the maps instance of the Albedo one (after setting all the attributes of course). You will be able to control the overall projection scale ;)

Cheers !
Démian
Isotropix
Technical Artist - Clarisse Specialist
User avatar
dboude
 
Posts: 518
Joined: Mon Jul 03, 2017 11:51 am

Re: Megascans Surfaces to Clarisse

Unread postby ivo3ds » Thu Mar 15, 2018 2:21 pm

Hi all,

Testing this script in the PLE, it only works for me if I do an UV-scale of 1000 to get the correct dimensions.

Does this script works right out of the box, or should I always add the Constant Color to all UV Scale inputs?

Is there a better way to have directly the correct scale (units preference e.g.)?

Thanks,

Ivo
ivo3ds
 
Posts: 17
Joined: Tue Dec 05, 2017 10:28 am

Re: Megascans Surfaces to Clarisse

Unread postby jandersunstar » Thu Mar 15, 2018 7:44 pm

Thanks all for your feedback,

I set the correct shader map for the Specular Color to be the Specular Texture (TRI_SPC), and there is also the TRI_GLOS ready if you find that it works better for your shader.

I added a multiplier for the size of the texture (physicalSizeMult) and for the intensity of the displacement (displacementHeightMult), right now is set to 1, but you can change it to 10 for example.

I also added a variable for the default value when there is not a json file with the correct information, right now is set to 1 (physicalSize) for 1m, but you can change it to 10 for example, the same for the displacement (displacementHeight), right now is set to 0.

Is there an easy way to make all the other maps to be instances of Albedo by python? And sometimes there are not an albedo texture map in the Megascans shaders.

Here is the updated script:

Code: Select all
# This script creates a MaterialPhysicalStandard shader from a folder
# containing images comming from Megascans.
#
# It will get the info of the heigth and the scanned area from the json file
# that should be in the same file as the images. If the displacement is wrong
# you can change the size from the _HEIGHT_DIS node in the input 2. A value
# of 1 equals 1 meters.
#
# The size of the texture is define in the UV of each TextureMap, you can change
# the size modifying these values. 1.0x equals 1 meters.
#
# You can multiply the size of the texture using the variable physicalSizeMult and
# the displacement intenisty with displacementHeightMult.
#
# If the script can't find the json file it will use the value of the variables physicalSize
# and displacementHeight to define your default value.
#
# The are three tag colors, Pink is the original shader (I use this color to easily
# find the Shader and Displacement nodes), Yellow is a variation with 90 rotation.
# And green is the blend of the two, to break a little the tile/repetition.
#
#
# It won't assign the shader to a geometry.
#
# This script was made by modifying the ibl.py script provided by Clarisse.
#
# Luis Montemayor
#
#
from os import listdir
from os.path import isfile, join
import json


extensions = 'All Known Files...\t*.{exr,tif,tx,hdr,tga,png,jpg,jpeg,bmp,sgi,psd,pic}\n\
Open EXR \t*.{exr}\nTIFF \t*.{tif}\nTX \t*.{tx}\n\
HDR \t*.{hdr}\nTarga \t*.{tga}\nPNG \t*.{png}\nJPG \t*.{jpg}\n\
JPEG \t*.{jpeg}\nBMP \t*.{bmp}\nSGI \t*.{sgi}\nPSD \t*.{psd}\n\
PIC \t*.{pic}'
file = ix.api.GuiWidget.open_file(ix.application, '', 'Browse for an image', extensions)
if file != "":
    ix.begin_command_batch("Build Shader")
    path = file.split('/')
    path.pop(-1)
    folder_name = file.split('/').pop(-2)
    context = ix.cmds.CreateContext(folder_name)
    path =  "/".join(path)
    onlyfiles = [f for f in listdir(path) if isfile(join(path, f))]

    # OTHER SETTINGS
    # Object space 2 = WORLD
    # Object space 3 = Object Deforemed
    object_space_value = "3"
    variance_rotation = "90"
    physicalSizeMult = 1
    displacementHeightMult = 1

    # Define Variables for empty json file
    displacementHeight = '0'
    physicalSize = '1'
    data = '';

    # Define Variables for empty textures
    txAlbedo = ''
    txRougness = ''
    txSpecular = ''
    txCavity = ''
    txNormal = ''
    txSpecular = ''
    txRougness = ''
    txGloss = ''
    txBump = ''
    txAlbedo = ''
    txAO = ''
    txDisplacement = ''

    # Define variables for arrays
    stand_mat = []
    triALB = []
    triSPC = []
    triROU = []
    triBMP = []
    triNOR = []
    triDIS = []
    triGLOS = []
    triAO = []
    triCAV = []
    heiDIS = []

    for file in onlyfiles:
        if file.lower().endswith(('.png', '.jpg', '.jpeg', '.json', '.exr')):
            if '_Normal.' in file:
                normal_tx = path + '/' + file
                txNormal = ix.cmds.CreateObject(folder_name + '_Normal_tx', 'TextureMapFile', context)
                txNormal.attrs.filename = normal_tx
                txNormal.attrs.color_space_auto_detect = False
                txNormal.attrs.file_color_space = 'linear'
                txNormal.attrs.projection = '3'
                txNormal.attrs.object_space = object_space_value

            elif '_Specular.' in file:
                specular_tx = path + '/' + file
                txSpecular = ix.cmds.CreateObject(folder_name + '_Specular_tx', 'TextureMapFile', context)
                txSpecular.attrs.filename = specular_tx
                txSpecular.attrs.color_space_auto_detect = False
                txSpecular.attrs.file_color_space = 'linear'
                txSpecular.attrs.projection = '3'
                txSpecular.attrs.object_space = object_space_value

            elif '_Roughness.' in file:
                roughness_tx = path + '/' + file
                txRougness = ix.cmds.CreateObject(folder_name + '_Roughness_tx', 'TextureMapFile', context)
                txRougness.attrs.filename = roughness_tx
                txRougness.attrs.color_space_auto_detect = False
                txRougness.attrs.single_channel_file_behavior = 1
                txRougness.attrs.file_color_space = 'linear'
                txRougness.attrs.projection = '3'
                txRougness.attrs.object_space = object_space_value

            elif '_Gloss.' in file:
                gloss_tx = path + '/' + file
                txGloss = ix.cmds.CreateObject(folder_name + '_Gloss_tx', 'TextureMapFile', context)
                txGloss.attrs.filename = gloss_tx
                txGloss.attrs.color_space_auto_detect = False
                txGloss.attrs.single_channel_file_behavior = 1
                txGloss.attrs.file_color_space = 'linear'
                txGloss.attrs.projection = '3'
                txGloss.attrs.object_space = object_space_value

            elif '_Albedo.' in file:
                albedo_tx = path + '/' + file
                txAlbedo = ix.cmds.CreateObject(folder_name + '_Albedo_tx', 'TextureMapFile', context)
                txAlbedo.attrs.filename = albedo_tx
                txAlbedo.attrs.color_space_auto_detect = False
                txAlbedo.attrs.single_channel_file_behavior = 1
                txAlbedo.attrs.file_color_space = 'sRGB'
                txAlbedo.attrs.projection = '3'
                txAlbedo.attrs.object_space = object_space_value

            elif '_AO.' in file:
                ao_tx = path + '/' + file
                txAO = ix.cmds.CreateObject(folder_name + '_AO_tx', 'TextureMapFile', context)
                txAO.attrs.filename = ao_tx
                txAO.attrs.color_space_auto_detect = False
                txAO.attrs.single_channel_file_behavior = 1
                txAO.attrs.file_color_space = 'sRGB'
                txAO.attrs.projection = '3'
                txAO.attrs.object_space = object_space_value

            elif '_Bump.' in file:
                bump_tx = path + '/' + file
                txBump = ix.cmds.CreateObject(folder_name + '_Bump_tx', 'TextureMapFile', context)
                txBump.attrs.filename = bump_tx
                txBump.attrs.color_space_auto_detect = False
                txBump.attrs.single_channel_file_behavior = 1
                txBump.attrs.file_color_space = 'linear'
                txBump.attrs.projection = '3'
                txBump.attrs.object_space = object_space_value

            elif '_Cavity.' in file:
                cavity_tx = path + '/' + file
                txCavity = ix.cmds.CreateObject(folder_name + '_Cavity_tx', 'TextureMapFile', context)
                txCavity.attrs.filename = cavity_tx
                txCavity.attrs.color_space_auto_detect = False
                txCavity.attrs.single_channel_file_behavior = 1
                txCavity.attrs.file_color_space = 'sRGB'
                txCavity.attrs.projection = '3'
                txCavity.attrs.object_space = object_space_value

            elif '_Displacement.' in file:
                displacement_tx = path + '/' + file
                txDisplacement = ix.cmds.CreateObject(folder_name + '_Displacement_tx', 'TextureMapFile', context)
                txDisplacement.attrs.filename = displacement_tx
                txDisplacement.attrs.color_space_auto_detect = False
                txDisplacement.attrs.single_channel_file_behavior = 1
                txDisplacement.attrs.file_color_space = 'linear'
                txDisplacement.attrs.projection = '3'
                txDisplacement.attrs.object_space = object_space_value

            elif '.json' in file:
                with open(path + '/' + file) as json_data:
                    data = json.load(json_data)

    # Define Variables from json
    if data != "":
        displacementHeight = data['meta'][1]['value']
        displacementHeight = displacementHeight.split(' ')
        displacementHeight = float(displacementHeight[0])
        displacementHeight = displacementHeight * displacementHeightMult
        displacementHeight = str(displacementHeight)
        physicalSize = data['meta'][0]['value'].split('x')
        physicalSize = float(physicalSize[0])
        physicalSize = physicalSize * physicalSizeMult
        physicalSize = str(physicalSize)

    # Create a loop of two iterations to create a little variations and break the repetition.
    for i in range(2):
        # Create Physical Shader and assgin the PINK color
        stand_mat.append(i)
        stand_mat[i] = ix.cmds.CreateObject(folder_name + '_SHD', 'MaterialPhysicalStandard', context)
        ix.cmds.ColorTagItems([stand_mat[i].get_full_name()], "pink")
        if i == 1:
            ix.cmds.ColorTagItems([stand_mat[i].get_full_name()], "yellow")

        if txAlbedo != "":
            triALB.append(i)
            triALB[i] = ix.cmds.CreateObject(folder_name + '_TRI_ALB', "TextureTriplanar", "", context)
            ix.cmds.SetValues([triALB[i].get_full_name() + ".blend"], ["0.5"])
            ix.cmds.SetValues([triALB[i].get_full_name() + ".object_space"], [object_space_value])
            ix.cmds.SetTexture([triALB[i].get_full_name() + ".right"], txAlbedo.get_full_name())
            ix.cmds.SetTexture([triALB[i].get_full_name() + ".left"], txAlbedo.get_full_name())
            ix.cmds.SetTexture([triALB[i].get_full_name() + ".top"], txAlbedo.get_full_name())
            ix.cmds.SetTexture([triALB[i].get_full_name() + ".bottom"], txAlbedo.get_full_name())
            ix.cmds.SetTexture([triALB[i].get_full_name() + ".front"], txAlbedo.get_full_name())
            ix.cmds.SetTexture([triALB[i].get_full_name() + ".back"], txAlbedo.get_full_name())
            if i == 1:
                ix.cmds.SetValues([triALB[i].get_full_name() + ".rotate[1]"], [variance_rotation])
            ix.cmds.SetTexture([stand_mat[i].get_full_name() + ".diffuse_front_color"], triALB[i].get_full_name())
            ix.cmds.SetValues([txAlbedo.get_full_name() + ".uv_scale[0]"], [physicalSize])
            ix.cmds.SetValues([txAlbedo.get_full_name() + ".uv_scale[1]"], [physicalSize])
            ix.cmds.SetValues([txAlbedo.get_full_name() + ".uv_scale[2]"], [physicalSize])

        if txRougness != "":
            triROU.append(i)
            triROU[i] = ix.cmds.CreateObject(folder_name + '_TRI_ROU', "TextureTriplanar", "", context)
            ix.cmds.SetValues([triROU[i].get_full_name() + ".blend"], ["0.5"])
            ix.cmds.SetValues([triROU[i].get_full_name() + ".object_space"], [object_space_value])
            ix.cmds.SetTexture([triROU[i].get_full_name() + ".right"], txRougness.get_full_name())
            ix.cmds.SetTexture([triROU[i].get_full_name() + ".left"], txRougness.get_full_name())
            ix.cmds.SetTexture([triROU[i].get_full_name() + ".top"], txRougness.get_full_name())
            ix.cmds.SetTexture([triROU[i].get_full_name() + ".bottom"], txRougness.get_full_name())
            ix.cmds.SetTexture([triROU[i].get_full_name() + ".front"], txRougness.get_full_name())
            ix.cmds.SetTexture([triROU[i].get_full_name() + ".back"], txRougness.get_full_name())
            if i == 1:
                ix.cmds.SetValues([triROU[i].get_full_name() + ".rotate[1]"], [variance_rotation])
            ix.cmds.SetTexture([stand_mat[i].get_full_name() + ".specular_1_roughness"], triROU[i].get_full_name())
            ix.cmds.SetValues([txRougness.get_full_name() + ".uv_scale[0]"], [physicalSize])
            ix.cmds.SetValues([txRougness.get_full_name() + ".uv_scale[1]"], [physicalSize])
            ix.cmds.SetValues([txRougness.get_full_name() + ".uv_scale[2]"], [physicalSize])

        if txGloss != "":
            triGLOS.append(i)
            triGLOS[i] = ix.cmds.CreateObject(folder_name + '_TRI_GLOS', "TextureTriplanar", "", context)
            ix.cmds.SetValues([triGLOS[i].get_full_name() + ".blend"], ["0.5"])
            ix.cmds.SetValues([triGLOS[i].get_full_name() + ".object_space"], [object_space_value])
            ix.cmds.SetTexture([triGLOS[i].get_full_name() + ".right"], txGloss.get_full_name())
            ix.cmds.SetTexture([triGLOS[i].get_full_name() + ".left"], txGloss.get_full_name())
            ix.cmds.SetTexture([triGLOS[i].get_full_name() + ".top"], txGloss.get_full_name())
            ix.cmds.SetTexture([triGLOS[i].get_full_name() + ".bottom"], txGloss.get_full_name())
            ix.cmds.SetTexture([triGLOS[i].get_full_name() + ".front"], txGloss.get_full_name())
            ix.cmds.SetTexture([triGLOS[i].get_full_name() + ".back"], txGloss.get_full_name())
            if i == 1:
                ix.cmds.SetValues([triGLOS[i].get_full_name() + ".rotate[1]"], [variance_rotation])
            ix.cmds.SetTexture([stand_mat[i].get_full_name() + ".specular_1_color"], triGLOS[i].get_full_name())
            ix.cmds.SetValues([txGloss.get_full_name() + ".uv_scale[0]"], [physicalSize])
            ix.cmds.SetValues([txGloss.get_full_name() + ".uv_scale[1]"], [physicalSize])
            ix.cmds.SetValues([txGloss.get_full_name() + ".uv_scale[2]"], [physicalSize])

        # if there are not Specular map it would use the Gloss instead.
        if txSpecular != "":
            triSPC.append(i)
            triSPC[i] = ix.cmds.CreateObject(folder_name + '_TRI_SPC', "TextureTriplanar", "", context)
            ix.cmds.SetValues([triSPC[i].get_full_name() + ".blend"], ["0.5"])
            ix.cmds.SetValues([triSPC[i].get_full_name() + ".object_space"], [object_space_value])
            ix.cmds.SetTexture([triSPC[i].get_full_name() + ".right"], txSpecular.get_full_name())
            ix.cmds.SetTexture([triSPC[i].get_full_name() + ".left"], txSpecular.get_full_name())
            ix.cmds.SetTexture([triSPC[i].get_full_name() + ".top"], txSpecular.get_full_name())
            ix.cmds.SetTexture([triSPC[i].get_full_name() + ".bottom"], txSpecular.get_full_name())
            ix.cmds.SetTexture([triSPC[i].get_full_name() + ".front"], txSpecular.get_full_name())
            ix.cmds.SetTexture([triSPC[i].get_full_name() + ".back"], txSpecular.get_full_name())
            if i == 1:
                ix.cmds.SetValues([triSPC[i].get_full_name() + ".rotate[1]"], [variance_rotation])
            ix.cmds.SetTexture([stand_mat[i].get_full_name() + ".specular_1_color"], triSPC[i].get_full_name())
            ix.cmds.SetValues([txSpecular.get_full_name() + ".uv_scale[0]"], [physicalSize])
            ix.cmds.SetValues([txSpecular.get_full_name() + ".uv_scale[1]"], [physicalSize])
            ix.cmds.SetValues([txSpecular.get_full_name() + ".uv_scale[2]"], [physicalSize])

        if txBump != "":
            triBMP.append(i)
            triBMP[i] = ix.cmds.CreateObject(folder_name + '_TRI_BMP', "TextureTriplanar", "", context)
            ix.cmds.SetValues([triBMP[i].get_full_name() + ".blend"], ["0.5"])
            ix.cmds.SetValues([triBMP[i].get_full_name() + ".object_space"], [object_space_value])
            ix.cmds.SetTexture([triBMP[i].get_full_name() + ".right"], txBump.get_full_name())
            ix.cmds.SetTexture([triBMP[i].get_full_name() + ".left"], txBump.get_full_name())
            ix.cmds.SetTexture([triBMP[i].get_full_name() + ".top"], txBump.get_full_name())
            ix.cmds.SetTexture([triBMP[i].get_full_name() + ".bottom"], txBump.get_full_name())
            ix.cmds.SetTexture([triBMP[i].get_full_name() + ".front"], txBump.get_full_name())
            ix.cmds.SetTexture([triBMP[i].get_full_name() + ".back"], txBump.get_full_name())
            if i == 1:
                ix.cmds.SetValues([triBMP[i].get_full_name() + ".rotate[1]"], [variance_rotation])
            txBP = ix.cmds.CreateObject(folder_name + '_BMP', "TextureBumpMap", "", context)
            ix.cmds.SetValues([txBP.get_full_name() + ".input"], [displacementHeight])
            ix.cmds.SetTexture([stand_mat[i].get_full_name() + ".normal_input"], txBP.get_full_name())
            ix.cmds.SetTexture([txBP.get_full_name() + ".input"], triBMP[i].get_full_name())
            ix.cmds.SetValues([txBump.get_full_name() + ".uv_scale[0]"], [physicalSize])
            ix.cmds.SetValues([txBump.get_full_name() + ".uv_scale[1]"], [physicalSize])
            ix.cmds.SetValues([txBump.get_full_name() + ".uv_scale[2]"], [physicalSize])

        # If there is a Normal Map then use this instead of the Bump
        if txNormal != "":
            triNOR.append(i)
            triNOR[i] = ix.cmds.CreateObject(folder_name + '_TRI_NOR', "TextureTriplanar", "", context)
            ix.cmds.SetValues([triNOR[i].get_full_name() + ".blend"], ["0.5"])
            ix.cmds.SetValues([triNOR[i].get_full_name() + ".object_space"], [object_space_value])
            ix.cmds.SetTexture([triNOR[i].get_full_name() + ".right"], txNormal.get_full_name())
            ix.cmds.SetTexture([triNOR[i].get_full_name() + ".left"], txNormal.get_full_name())
            ix.cmds.SetTexture([triNOR[i].get_full_name() + ".top"], txNormal.get_full_name())
            ix.cmds.SetTexture([triNOR[i].get_full_name() + ".bottom"], txNormal.get_full_name())
            ix.cmds.SetTexture([triNOR[i].get_full_name() + ".front"], txNormal.get_full_name())
            ix.cmds.SetTexture([triNOR[i].get_full_name() + ".back"], txNormal.get_full_name())
            if i == 1:
                ix.cmds.SetValues([triNOR[i].get_full_name() + ".rotate[1]"], [variance_rotation])
            txNM = ix.cmds.CreateObject(folder_name + '_NOR', "TextureNormalMap", "", context)
            ix.cmds.SetTexture([stand_mat[i].get_full_name() + ".normal_input"], txNM.get_full_name())
            ix.cmds.SetTexture([txNM.get_full_name() + ".input"], triNOR[i].get_full_name())
            ix.cmds.SetValues([txNormal.get_full_name() + ".uv_scale[0]"], [physicalSize])
            ix.cmds.SetValues([txNormal.get_full_name() + ".uv_scale[1]"], [physicalSize])
            ix.cmds.SetValues([txNormal.get_full_name() + ".uv_scale[2]"], [physicalSize])

        # Create Displacement Shader and assgin the PINK color
        if txDisplacement != "":
            triDIS.append(i)
            triDIS[i] = ix.cmds.CreateObject(folder_name + '_TRI_DIS', "TextureTriplanar", "", context)
            ix.cmds.SetValues([triDIS[i].get_full_name() + ".blend"], ["0.5"])
            ix.cmds.SetValues([triDIS[i].get_full_name() + ".object_space"], [object_space_value])
            ix.cmds.SetTexture([triDIS[i].get_full_name() + ".right"], txDisplacement.get_full_name())
            ix.cmds.SetTexture([triDIS[i].get_full_name() + ".left"], txDisplacement.get_full_name())
            ix.cmds.SetTexture([triDIS[i].get_full_name() + ".top"], txDisplacement.get_full_name())
            ix.cmds.SetTexture([triDIS[i].get_full_name() + ".bottom"], txDisplacement.get_full_name())
            ix.cmds.SetTexture([triDIS[i].get_full_name() + ".front"], txDisplacement.get_full_name())
            ix.cmds.SetTexture([triDIS[i].get_full_name() + ".back"], txDisplacement.get_full_name())
            if i == 1:
                ix.cmds.SetValues([triDIS[i].get_full_name() + ".rotate[1]"], [variance_rotation])
            heiDIS.append(i)
            heiDIS[i] = ix.cmds.CreateObject(folder_name + '_HEIGHT_DIS', "TextureMultiply", "", context)
            ix.cmds.ColorTagItems([heiDIS[i].get_full_name()], "violet")
            if i == 1:
                ix.cmds.ColorTagItems([heiDIS[i].get_full_name()], "dark_yellow")
            ix.cmds.SetTexture([heiDIS[i].get_full_name() + ".input1"], triDIS[i].get_full_name())
            print displacementHeight
            ix.cmds.SetValues([heiDIS[i].get_full_name() + ".input2"], [displacementHeight, displacementHeight, displacementHeight])
            displacement = ix.cmds.CreateObject(folder_name + '_DIS', "Displacement", context)
            ix.cmds.SetTexture([displacement.get_full_name() + ".front_value"], heiDIS[i].get_full_name())
            ix.cmds.SetValues([displacement.get_full_name() + ".front_value"], ["1"])
            ix.cmds.SetValues([displacement.get_full_name() + ".bound[0]"], [displacementHeight])
            ix.cmds.SetValues([displacement.get_full_name() + ".bound[1]"], [displacementHeight])
            ix.cmds.SetValues([displacement.get_full_name() + ".bound[2]"], [displacementHeight])
            ix.cmds.SetValues([txDisplacement.get_full_name() + ".uv_scale[0]"], [physicalSize])
            ix.cmds.SetValues([txDisplacement.get_full_name() + ".uv_scale[1]"], [physicalSize])
            ix.cmds.SetValues([txDisplacement.get_full_name() + ".uv_scale[2]"], [physicalSize])
            ix.cmds.SetValues([txDisplacement.get_full_name() + ".uv_scale[2]"], [physicalSize])
            ix.cmds.ColorTagItems([displacement.get_full_name()], "pink")
            if i == 1:
                ix.cmds.ColorTagItems([displacement.get_full_name()], "yellow")


        if txAO != "":
            triAO.append(i)
            triAO[i] = ix.cmds.CreateObject(folder_name + '_TRI_AO', "TextureTriplanar", "", context)
            ix.cmds.SetValues([triAO[i].get_full_name() + ".blend"], ["0.5"])
            ix.cmds.SetValues([triAO[i].get_full_name() + ".object_space"], [object_space_value])
            ix.cmds.SetTexture([triAO[i].get_full_name() + ".right"], txAO.get_full_name())
            ix.cmds.SetTexture([triAO[i].get_full_name() + ".left"], txAO.get_full_name())
            ix.cmds.SetTexture([triAO[i].get_full_name() + ".top"], txAO.get_full_name())
            ix.cmds.SetTexture([triAO[i].get_full_name() + ".bottom"], txAO.get_full_name())
            ix.cmds.SetTexture([triAO[i].get_full_name() + ".front"], txAO.get_full_name())
            ix.cmds.SetTexture([triAO[i].get_full_name() + ".back"], txAO.get_full_name())
            if i == 1:
                ix.cmds.SetValues([triAO[i].get_full_name() + ".rotate[1]"], [variance_rotation])
            txAO_MUL = ix.cmds.CreateObject(folder_name + '_MUL_AO', "TextureMultiply", "", context)
            ix.cmds.SetTexture([txAO_MUL.get_full_name() + ".input2"], triAO[i].get_full_name())
            ix.cmds.SetTexture([txAO_MUL.get_full_name() + ".input1"], triALB[i].get_full_name())
            ix.cmds.SetTexture([stand_mat[i].get_full_name() + ".diffuse_front_color"], txAO_MUL.get_full_name())
            ix.cmds.SetValues([txAO.get_full_name() + ".uv_scale[0]"], [physicalSize])
            ix.cmds.SetValues([txAO.get_full_name() + ".uv_scale[1]"], [physicalSize])
            ix.cmds.SetValues([txAO.get_full_name() + ".uv_scale[2]"], [physicalSize])

        if txCavity != "":
            triCAV.append(i)
            triCAV[i] = ix.cmds.CreateObject(folder_name + '_TRI_CAV', "TextureTriplanar", "", context)
            ix.cmds.SetValues([triCAV[i].get_full_name() + ".blend"], ["0.5"])
            ix.cmds.SetValues([triCAV[i].get_full_name() + ".object_space"], [object_space_value])
            ix.cmds.SetTexture([triCAV[i].get_full_name() + ".right"], txCavity.get_full_name())
            ix.cmds.SetTexture([triCAV[i].get_full_name() + ".left"], txCavity.get_full_name())
            ix.cmds.SetTexture([triCAV[i].get_full_name() + ".top"], txCavity.get_full_name())
            ix.cmds.SetTexture([triCAV[i].get_full_name() + ".bottom"], txCavity.get_full_name())
            ix.cmds.SetTexture([triCAV[i].get_full_name() + ".front"], txCavity.get_full_name())
            ix.cmds.SetTexture([triCAV[i].get_full_name() + ".back"], txCavity.get_full_name())
            if i == 1:
                ix.cmds.SetValues([triCAV[i].get_full_name() + ".rotate[1]"], [variance_rotation])
            txCAV_MUL = ix.cmds.CreateObject(folder_name + '_MUL_CAV', "TextureMultiply", "", context)
            txCAV_RES_MUL = ix.cmds.CreateObject(folder_name + '_RES_CAV_MUL', "TextureRescale", "", context)
            ix.cmds.SetTexture([txCAV_RES_MUL.get_full_name() + ".input"], triCAV[i].get_full_name())
            ix.cmds.SetValues([txCAV_RES_MUL.get_full_name() + ".input_max"], ["0.5", "0.5", "0.5"])
            ix.cmds.SetTexture([txCAV_MUL.get_full_name() + ".input2"], txCAV_RES_MUL.get_full_name())
            if txAO != "":
                ix.cmds.SetTexture([txCAV_MUL.get_full_name() + ".input1"], txAO_MUL.get_full_name())       
            else:
                ix.cmds.SetTexture([txCAV_MUL.get_full_name() + ".input1"], triALB[i].get_full_name())       

            ix.cmds.SetTexture([stand_mat[i].get_full_name() + ".diffuse_front_color"], txCAV_MUL.get_full_name())
            ix.cmds.SetValues([txCavity.get_full_name() + ".uv_scale[0]"], [physicalSize])
            ix.cmds.SetValues([txCavity.get_full_name() + ".uv_scale[1]"], [physicalSize])
            ix.cmds.SetValues([txCavity.get_full_name() + ".uv_scale[2]"], [physicalSize])

    # Create MaterialPhysicalBlend and assign the GREEN color
    blend_mat = ix.cmds.CreateObject(folder_name + '_BLEND_SHD', 'MaterialPhysicalBlend', context)
    ix.cmds.ColorTagItems([blend_mat.get_full_name()], "green")
    ix.cmds.SetValues([blend_mat.get_full_name() + ".input1"], [stand_mat[0]])
    ix.cmds.SetValues([blend_mat.get_full_name() + ".input2"], [stand_mat[1]])

    fractal_noise = ix.cmds.CreateObject(folder_name + '_BlendNoise', 'TextureFractalNoise', context)
    ix.cmds.SetValues([fractal_noise.get_full_name() + ".projection"], ["3"])
    ix.cmds.SetValues([fractal_noise.get_full_name() + ".object_space"], [object_space_value])
    ix.cmds.SetValues([fractal_noise.get_full_name() + ".contrast"], ["0.9"])
    ix.cmds.SetValues([fractal_noise.get_full_name() + ".color1"], ["1", "1", "1"])
    ix.cmds.SetTexture([blend_mat.get_full_name() + ".mix"], fractal_noise.get_full_name())
    if txDisplacement != "":
        blend_displacement = ix.cmds.CreateObject(folder_name + '_BLEND_DIS', "Displacement", context)
        ix.cmds.ColorTagItems([blend_displacement.get_full_name()], "green")
       
        disBlend = ix.cmds.CreateObject(folder_name + '_DisBlend', 'TextureBlend', context)
        ix.cmds.ColorTagItems([disBlend.get_full_name()], "dark_green")
        ix.cmds.SetTexture([disBlend.get_full_name() + ".input1"], heiDIS[0])
        ix.cmds.SetTexture([disBlend.get_full_name() + ".input2"], heiDIS[1])

        ix.cmds.SetTexture([blend_displacement.get_full_name() + ".front_value"], disBlend.get_full_name())
        ix.cmds.SetValues([blend_displacement.get_full_name() + ".front_value"], ["1"])
        ix.cmds.SetValues([blend_displacement.get_full_name() + ".bound[0]"], [displacementHeight])
        ix.cmds.SetValues([blend_displacement.get_full_name() + ".bound[1]"], [displacementHeight])
        ix.cmds.SetValues([blend_displacement.get_full_name() + ".bound[2]"], [displacementHeight])
        ix.cmds.SetTexture([disBlend.get_full_name() + ".mix"], fractal_noise.get_full_name())

    ix.end_command_batch()

else:
    ix.log_warning('This script has been aborted.')
User avatar
jandersunstar
 
Posts: 252
Joined: Fri Jun 06, 2014 9:21 pm
Location: Mexico City

Next

Return to Scripting