The script automatically creates octane images texture nodes with correct UV tile transform, and connect all tiles together.
usage:
create an octane Image node pointing to one of the UDIM files, and run the script,
that's all !
As usual to execute the script you can paste it in a python tab in the script editor or drop it in a shelf as a python button.
You can also use other tiling mode than UDIM if you change in the script the "mode" number.
tiling mode: 0=OFF, 1=ZBRUSH, 2=MUDBOX, 3=UDIM, 4=EXPLICIT
v 0.2: added a viewport shader override to display the texture in viewport 2.0.
- Code: Select all
# octane_UDIM_tile version 0.2
# select an octane Texture pointing to one of the UDIM file
# and execute this script from a python tab in the script editor
# or with a shelf python button.
# you can use other tiling mode than UDIM if you change in the script the "mode" number.
# tiling mode: 0=OFF, 1=ZBRUSH, 2=MUDBOX, 3=UDIM, 4=EXPLICIT
#
# added in v 0.2 : override the dislpay in viewport with a Maya shader
import maya.cmds as cmd
import maya.app.general.fileTexturePathResolver as fr
def octane_tile(node, mode):
name = cmd.getAttr(node+".File")
name = cmd.file(name, q=True, exn=True)
token = fr.getFilePatternString(name, False, mode)
pathes = fr.findAllFilesForPattern(token, 1)
uvs = fr.computeUVForFiles(pathes, token)
if len(pathes) > 0 :
for n in range(len(pathes)):
if n == 0 :
node_a = node
else:
last_node_a = node_a
node_a = cmd.createNode("octaneImageTexture")
cmd.connectAttr(node_a+".outTex", last_node_a+".Power")
cmd.setAttr(node_a+".File", pathes[n], type="string")
node_b = cmd.createNode("octaneTransform2D")
cmd.setAttr(node_a+".BorderMode", 2)
cmd.setAttr(node_b+".TranslationX", uvs[n*2])
cmd.setAttr(node_b+".TranslationY", uvs[n*2+1])
cmd.connectAttr(node_b+".outTransform", node_a+".Transform")
connected = cmd.listConnections(node, d=True, s=False)
shaders = cmd.ls(connected, typ=["octaneDiffuseMaterial", "octaneGlossyMaterial", "octaneSpecularMaterial"])
if len(shaders) > 0 :
for shader in shaders :
if not cmd.ls(shader+".hardwareShader"):
cmd.addAttr(shader, ln="hardwareShader", usedAsColor=True, h=False, attributeType="float3")
cmd.addAttr(shader, ln="colorR", attributeType="float", parent="hardwareShader")
cmd.addAttr(shader, ln="colorG", attributeType="float", parent="hardwareShader")
cmd.addAttr(shader, ln="colorB", attributeType="float", parent="hardwareShader")
viewport_shader = cmd.createNode("lambert", name="viewport_shader")
viewport_texture = cmd.createNode("file", name="viewport_texture")
cmd.connectAttr(viewport_shader+".outColor", shader+".hardwareShader")
cmd.connectAttr(viewport_texture+".outColor", viewport_shader+".color")
cmd.setAttr(viewport_texture+".fileTextureName", name, type="string")
cmd.setAttr(viewport_texture+".uvTilingMode", mode)
cmd.ogs(regenerateUVTilePreview=viewport_texture)
mode = 3 # tiling mode: 0=OFF, 1=ZBRUSH, 2=MUDBOX, 3=UDIM, 4=EXPLICIT
nodes = cmd.ls(sl=True, type="octaneImageTexture")
for node in nodes:
octane_tile(node, mode)