1

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

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

请参阅所附图片,但是当我从Hypershade.

这是一张图片

4

2 回答 2

1

您需要重新申请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

希望这可以帮助!

于 2017-04-29T14:47:22.293 回答
1

完美,在我的情况下,将文件格式设置为“原始”后,它可以正常工作,谢谢安迪。

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()
于 2017-04-30T00:05:40.047 回答