SCRIPT : UDIM tiles with Octane plugin

Forums: SCRIPT : UDIM tiles with Octane plugin
Sub forum for help and tutorials.

Moderator: JimStar

SCRIPT : UDIM tiles with Octane plugin

Postby calus » Sun Aug 14, 2016 3:51 pm

calus Sun Aug 14, 2016 3:51 pm
As a lot of people were asking for UDIM support in the Octane plugin, I made this python script for that.
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.


octane_UDIM_tile_0.2.py.zip
(1.13 KiB) Downloaded 482 times


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)
Last edited by calus on Tue Aug 16, 2016 3:59 pm, edited 4 times in total.
Pascal ANDRE
calus
Licensed Customer
Licensed Customer
 
Posts: 1308
Joined: Sat May 22, 2010 9:31 am
Location: Paris

Re: SCRIPT : UDIM tiles with Octane plugin

Postby mosssi » Mon Aug 15, 2016 8:34 am

mosssi Mon Aug 15, 2016 8:34 am
Hey calus
Thank you for your kindness. I'm grateful about your effort. So I tried your scripts and it works.
Just a quick question for now:
I can't see the textures in the veiwport, can we change the script to show textures? is it doable?

Thank you
Maya 2016 SP6, Windows 10 x64, 4 x GTX 980 Ti
mosssi
Licensed Customer
Licensed Customer
 
Posts: 37
Joined: Sun May 22, 2016 11:24 am

Re: SCRIPT : UDIM tiles with Octane plugin

Postby calus » Mon Aug 15, 2016 9:19 am

calus Mon Aug 15, 2016 9:19 am
mosssi wrote:I can't see the textures in the veiwport, can we change the script to show textures? is it doable?

not possible directly, octane texture viewport display is way too limited.

But you should use this other script for that, which override the display of octane shaders in viewport 2.0 with maya shaders :
viewtopic.php?f=28&t=52995&p=266550#p266550

I suppose I could add an option to do the override automatically in this script if the OctaneImageTexture node is already connected to an Octane material...

but what if the UDIM texture is used in a complex shader network using also other textures, which texture to dispay ?
and if it is used in several different shader ?
or if there's already a maya shader connected to overide the Octane shader, should I replace it ?
seems hard to guess what the user want to see, isn't it better to let him choose manualy which maya shader will override in viewport its Octane material?

What do you think ?


EDIT: thinking more about it, another way may be to hack the maya UDIM preview feature to be used also for octane texture, I'l have to try.
Pascal ANDRE
calus
Licensed Customer
Licensed Customer
 
Posts: 1308
Joined: Sat May 22, 2010 9:31 am
Location: Paris

Re: SCRIPT : UDIM tiles with Octane plugin

Postby mosssi » Mon Aug 15, 2016 9:57 am

mosssi Mon Aug 15, 2016 9:57 am
calus wrote:but what if it is used in a complex shader network using also other textures, which texture to dispay ?
and if it is used in several different shader ?
or if there's already a maya shader connected to overide the Octane shader, should I replace it ?
seems hard to guess what the user want to see, isn't it better to let the him choose manualy which maya shader will override in viewport its Octane material?

What do you think ?


EDIT: thinking more about it, another way may be to hack the maya UDIM preview feature to be used also for octane texture, I'l have to try.


I really don't want to be rude for asking too much favors I have a developer friend who can help inside the company but as you are more expert on octane itself so we can share ideas about the best choices for this script.
As I want to have textures visible in viewport for animators It's not really important to have the exact that we have in octane shading. Just a simple color from diffuse channel would be ok. Currently we implement a setup in our char rig which can be switched between octane shaders and maya shaders which means we have two sets of shaders.
I think the best thing for us is to shade a model in octane with UDIM and with a single click create a lambert with a file node (only diffuse channel) which is UDIM support itself and override it on each shaders.

Also I will send you a private massage now.
Maya 2016 SP6, Windows 10 x64, 4 x GTX 980 Ti
mosssi
Licensed Customer
Licensed Customer
 
Posts: 37
Joined: Sun May 22, 2016 11:24 am

Re: SCRIPT : UDIM tiles with Octane plugin

Postby k.a.schubert » Mon Aug 15, 2016 11:38 pm

k.a.schubert Mon Aug 15, 2016 11:38 pm
Thanks calus! :)
k.a.schubert
OctaneRender Team
OctaneRender Team
 
Posts: 137
Joined: Mon Feb 22, 2016 2:52 am

Re: SCRIPT : UDIM tiles with Octane plugin

Postby Slimshader » Tue Aug 16, 2016 2:42 pm

Slimshader Tue Aug 16, 2016 2:42 pm
Thanks!
User avatar
Slimshader
Licensed Customer
Licensed Customer
 
Posts: 92
Joined: Fri Sep 03, 2010 2:17 am
Location: Canada

Re: SCRIPT : UDIM tiles with Octane plugin

Postby calus » Tue Aug 16, 2016 3:08 pm

calus Tue Aug 16, 2016 3:08 pm
mosssi wrote:I can't see the textures in the veiwport, can we change the script to show textures? is it doable?

Added viewport preview in version 0.2.

(I updated the first post with the new version of the script)
Pascal ANDRE
calus
Licensed Customer
Licensed Customer
 
Posts: 1308
Joined: Sat May 22, 2010 9:31 am
Location: Paris

Re: SCRIPT : UDIM tiles with Octane plugin

Postby mosssi » Wed Aug 17, 2016 5:55 am

mosssi Wed Aug 17, 2016 5:55 am
calus wrote:(I updated the first post with the new version of the script)

Hi calus
I tested the v2 script and it's really great. Thank you man
But out of curiosity, what the power parameter do in a texture image node that you can use it for connecting other image textures?
Maya 2016 SP6, Windows 10 x64, 4 x GTX 980 Ti
mosssi
Licensed Customer
Licensed Customer
 
Posts: 37
Joined: Sun May 22, 2016 11:24 am

Re: SCRIPT : UDIM tiles with Octane plugin

Postby calus » Wed Aug 17, 2016 7:14 am

calus Wed Aug 17, 2016 7:14 am
mosssi wrote: what the power parameter do in a texture image node that you can use it for connecting other image textures?

The power attribute in Octane textures is exactly the same thing as the color gain attribute for Maya textures.
This is a multiplier and the simplest way to layer Octane textures together.

But as this attribute uses by default a slider instead of a RGB swatch like Maya color gain,
often users do not suspect they can plug another texture in it...
Pascal ANDRE
calus
Licensed Customer
Licensed Customer
 
Posts: 1308
Joined: Sat May 22, 2010 9:31 am
Location: Paris

Re: SCRIPT : UDIM tiles with Octane plugin

Postby mosssi » Wed Aug 17, 2016 7:56 am

mosssi Wed Aug 17, 2016 7:56 am
calus wrote:But as this attribute uses by default a slider instead of a RGB swatch like Maya color gain,
often users do not suspect they can plug another texture in it...

So the second texture which you connect to the power of the first texture, multiplies into black area of first one. is it true? So why does it is not black?
Maya 2016 SP6, Windows 10 x64, 4 x GTX 980 Ti
mosssi
Licensed Customer
Licensed Customer
 
Posts: 37
Joined: Sun May 22, 2016 11:24 am
Next

Return to Help / Tutorials


Who is online

Users browsing this forum: No registered users and 1 guest

Sun Jun 16, 2024 5:11 am [ UTC ]