change shader on all assigned meshes, without using hyperShade()

一世执手 提交于 2020-05-16 02:34:27

问题


I get all shapes assigned to baseMaterial, select the shapes and then assign the occlusionShader.

for materialClass in materialClassList:
    select(materialClass.baseMaterial)
    hyperShade(objects="")
    hyperShade(a=materialClass.occlusionShader)

works just fine, but if I use it as a pre render script:

  Error: line 0: hyperShade command not supported in batch mode

What can I change the two last lines of my function to to make this work?


回答1:


Here is an example with cmds.sets() to assign a shader :

all = cmds.ls(type='mesh')
shadingEngine = 'initialShadingGroup'
cmds.sets(all, e=True, forceElement=shadingEngine)

as you can guess, to query meshes with the material :

lamb1_mshs = cmds.sets(shadingEngine, q=True)



回答2:


i got it to work with:

for materialClass in materialClassList:
    sets(materialClass.occlusionShadingGroup, e = True, forceElement = materialClass.meshList)

I collect the meshes when I create the materialClass now, which makes much more sense then selecting them for each renderlayer.



来源:https://stackoverflow.com/questions/49035311/change-shader-on-all-assigned-meshes-without-using-hypershade

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!