python Maya shadingNode中的锁定文件纹理

webghufk  于 2022-12-17  发布在  Python
关注(0)|答案(2)|浏览(103)

我在这里使用shadingNode得到了一些奇怪的结果,每当我在Maya中通过Python创建文件节点时,我都会锁定颜色空间,颜色空间下拉菜单变灰。

fileNode = cmds.shadingNode( "file", asTexture=True, name="dispMap" )

请参见所附图片,但是当我从Hypershade中的创建着色器选项卡创建文件节点时,我得到了通常预期的结果。
Here's an image

ztigrdn8

ztigrdn81#

您需要重新应用Input Color Space Rules

import maya.cmds as cmds
import pymel.core as pm

shader = cmds.shadingNode( 'anisotropic', asShader=True )
file_node = cmds.shadingNode( 'file', asTexture=True, name="dispMap" )
# file = ( '/Users/me/Desktop/texture.jpg' )

shading_group = cmds.sets( renderable=True, noSurfaceShader=True, empty=True )
cmds.connectAttr( '%s.outColor' %shader , '%s.surfaceShader' %shading_group )
cmds.connectAttr( '%s.outColor' %file_node, '%s.color' %shader )

cmds.polySphere( n='mySphere', radius=5, sx=40, sy=30 )
cmds.select( 'mySphere', visible=True )
cmds.hyperShade( assign=shader )

colMgmtGlob = pm.PyNode( 'defaultColorMgtGlobals' )

for f in pm.ls( type='file' ):
    colMgmtGlob.cmEnabled >> f.colorManagementEnabled
    colMgmtGlob.configFileEnabled >> f.colorManagementConfigFileEnabled
    colMgmtGlob.configFilePath >> f.colorManagementConfigFilePath
    colMgmtGlob.workingSpaceName >> f.workingSpace
s4n0splo

s4n0splo2#

完美,它的工作,因为它应该设置后,文件格式为“原始”在我的情况下,感谢安迪。

import maya.cmds as cmds
import pymel.core as pm

fileNode = cmds.shadingNode("file",asTexture=True, name = "dispMap") 

def InputColorRules():
    colMgmtGlob = pm.PyNode( 'defaultColorMgtGlobals' )
    for f in pm.ls( type='file' ):
        colMgmtGlob.cmEnabled >> f.colorManagementEnabled
        colMgmtGlob.configFileEnabled >> f.colorManagementConfigFileEnabled
        colMgmtGlob.configFilePath >> f.colorManagementConfigFilePath
        colMgmtGlob.workingSpaceName >> f.workingSpace
        cmds.setAttr('%s.colorSpace' %f, 'Raw', type='string')

InputColorRules()

相关问题