Example #1
0
def newAOVPrompt(default=''):
    result = pm.cmds.promptDialog(button=['Create', 'Cancel'],
                                  defaultButton='Create',
                                  cancelButton='Cancel',
                                  message='AOV Name',
                                  title='New AOV',
                                  text=default)
    if result == 'Create':
        core.createOptions()
        newAOV = pm.promptDialog(
            query=True, text=True
        )  #[0:29] # channel names in the exr driver are limited to 29 characterss
        if len(newAOV) > 29:
            oldAOV = newAOV
            newAOV = newAOV[0:29]
            cmds.confirmDialog(
                message=
                "The name %s is longer than 29 characters, truncated to : %s" %
                (oldAOV, newAOV))
        if str(newAOV).replace("_", "").isalnum():
            return newAOV, aovs.AOVInterface().addAOV(newAOV)
        else:
            print "Invalid AOV Name"
            return None, None
    else:
        print "AOV creation canceled"
        return None, None
Example #2
0
def arnoldAOVBrowser(**kwargs):
    core.createOptions()
    win = pm.window(title='AOV Browser', width=640, height=300)
    browser = AOVBrowser(**kwargs)
    browser.populate()
    win.show()
    return browser
Example #3
0
def arnoldAOVBrowser(**kwargs):
    core.createOptions()
    win = pm.window(title='AOV Browser', width=640, height=300)
    browser = AOVBrowser(**kwargs)
    browser.populate()
    win.show()
    return browser
Example #4
0
def arnoldBatchRender(option):
    # Make sure the aiOptions node exists
    core.createOptions()
    # Parse option string
    kwargs = {}
    options = option.split(" ")
    i, n = 0, len(options)
    if cmds.objExists("defaultResolution.mtoaCommandPort"):
        kwargs["port"] = cmds.getAttr("defaultResolution.mtoaCommandPort")
    if cmds.objExists("defaultArnoldRenderOptions.mtoaOrigFileName"):
        kwargs["ofn"] = cmds.getAttr("defaultArnoldRenderOptions.mtoaOrigFileName")
    while i < n:
        if options[i] in ["-w", "-width"]:
            i += 1
            if i >= n:
                break
            kwargs["width"] = int(options[i])

        elif options[i] in ["-h", "-height"]:
            i += 1
            if i >= n:
                break
            kwargs["height"] = int(options[i])

        elif options[i] in ["-cam", "-camera"]:
            i += 1
            if i >= n:
                break
            kwargs["camera"] = options[i]
        i += 1
    try:
        cmds.arnoldRender(batch=True, **kwargs)
    except RuntimeError, err:
        print err
Example #5
0
 def clean_environment(self):
     # Open a new file to clear out any AOVs created by the tests
     pm.newFile(force=True)
     # defaultArnoldDriver (among other objects) doesn't load until needed.
     # The following 2 lines will force them to load to avoid runtime errors.
     from mtoa.core import createOptions
     createOptions()
Example #6
0
def MaskBuild():

    sel = cmds.ls(selection=True)

    aiMaskSets = []
    for node in sel:
        if cmds.nodeType(node) == 'objectSet':
            aiMaskSets.append(node)

    if not aiMaskSets:
        cmds.warning('No sets selected!')
        return

    core.createOptions()

    aiColor = cmds.shadingNode('aiUserDataColor', asShader=1)

    cmds.setAttr(aiColor + '.defaultValue', 1, 1, 1, typ='double3')

    for aiSet in xrange(0, len(aiMaskSets), 3):

        tSwitch = cmds.shadingNode('tripleShadingSwitch', au=1)
        cmds.setAttr(tSwitch + '.default', 0, 0, 0, typ='double3')

        aiUshader = cmds.shadingNode('aiUtility', asShader=1)
        cmds.setAttr(aiUshader + '.shadeMode', 2)
        cmds.connectAttr(tSwitch + '.output', aiUshader + '.color', f=1)

        for obj in cmds.listRelatives(cmds.sets(aiSet, q=1), pa=1):
            inpt = cmds.getAttr(tSwitch + '.input', s=1)
            if cmds.nodeType(obj) == 'mesh':
                cmds.connectAttr(obj + '.instObjGroups[0]',
                                 tSwitch + '.input[' + str(inpt) + '].inShape', f=1)
                cmds.connectAttr(aiColor + '.outColor',
                                 tSwitch + '.input[' + str(inpt) + '].inTriple', f=1)

        #AOV
        aovListSize = cmds.getAttr('defaultArnoldRenderOptions.aovList', s=1)

        customAOV = cmds.createNode('aiAOV',
                                    n='aiAOV_rgbMask',
                                    skipSelect=True)
        cmds.setAttr(customAOV + '.name', aiSet,
                     type='string')
        cmds.connectAttr(customAOV + '.message',
                         'defaultArnoldRenderOptions.aovList[' + str(aovListSize) + ']',
                         f=1)

        cmds.connectAttr('defaultArnoldDriver.message',
                         customAOV + '.outputs[0].driver', f=1)
        cmds.connectAttr('defaultArnoldFilter.message',
                         customAOV + '.outputs[0].filter', f=1)

        # connect to default shader
        cmds.connectAttr(aiUshader + '.outColor',
                         customAOV + '.defaultValue', f=1)
Example #7
0
def create_arnold_options():
    """
    Create the arnold render options

    :return:
    """

    core.createOptions()

    return
Example #8
0
	def render(self):
		try:
			cmds.arnoldIpr(mode='stop')
		except RuntimeError:
			pass

		defaultTranslator = cmds.getAttr("defaultArnoldDisplayDriver.aiTranslator")

		try:
			cmds.setAttr("defaultArnoldDisplayDriver.aiTranslator", "aton", type="string")
		except RuntimeError:
			cmds.warning("Aton driver for Arnold is not installed")
			return

		if self.cameraComboBox.currentIndex() == 0:
			camera = self.getSceneOptions()["camera"]
		else:
			camera = cmds.listRelatives(self.cameraComboBoxDict[self.cameraComboBox.currentIndex()], s=1)[0]

		width = self.getSceneOptions()["width"] * self.resolutionSpinBox.value() / 100
		height = self.getSceneOptions()["height"] * self.resolutionSpinBox.value() / 100
		AASamples = self.cameraAaSpinBox.value()
		motionBlur = not self.motionBlurCheckBox.isChecked()
		subdivs = not self.subdivsCheckBox.isChecked()
		displace = not self.displaceCheckBox.isChecked()
		bump = not self.bumpCheckBox.isChecked()
		sss = not self.sssCheckBox.isChecked()

		rMinX = self.renderRegionXSpinBox.value()
		rMinY = height - self.renderRegionTSpinBox.value()
		rMaxX = self.renderRegionRSpinBox.value() -1
		rMaxY = (height - self.renderRegionYSpinBox.value()) - 1
		print rMinX, rMinY, rMaxX, rMaxY
		core.createOptions()
		cmds.arnoldIpr(cam=camera, width=width, height=height, mode='start')
		nodeIter = AiUniverseGetNodeIterator(AI_NODE_ALL)

		while not AiNodeIteratorFinished(nodeIter):
			node = AiNodeIteratorGetNext(nodeIter)
			AiNodeSetInt(node, "AA_samples", AASamples)
			if rMinX >= 0 and rMinY>=0 and rMaxX<=width and rMaxY<=height:
				AiNodeSetInt(node, "region_min_x", rMinX)
				AiNodeSetInt(node, "region_min_y", rMinY)
				AiNodeSetInt(node, "region_max_x", rMaxX)
				AiNodeSetInt(node, "region_max_y", rMaxY)
			AiNodeSetBool(node, "ignore_motion_blur", motionBlur)
			AiNodeSetBool(node, "ignore_subdivision", subdivs)
			AiNodeSetBool(node, "ignore_displacement ", displace)
			AiNodeSetBool(node, "ignore_bump", bump)
			AiNodeSetBool(node, "ignore_sss", sss)

		# Temp trigger in order to start IPR immediately
		cmds.setAttr("%s.bestFitClippingPlanes"%camera, True)

		cmds.setAttr("defaultArnoldDisplayDriver.aiTranslator", defaultTranslator, type="string")
def setup_minimal_mtoa():
    # Load up defaultArnoldRenderOptions
    # this will also create defaultArnoldDisplayDriver etc. whose are necessary to set up AOVs
    from mtoa.core import createOptions
    createOptions()

    # Ignore errors - otherwise the batch render will fail with:
    # "aborting render pass setup:  received abort signal"
    # but no other obvious error messages
    cmds.setAttr("defaultArnoldRenderOptions.abortOnError", 0)

    # Set arnold log verbosity to Info so we can grab info
    # about rendering progress from console output
    cmds.setAttr("defaultArnoldRenderOptions.log_verbosity", 2)
Example #10
0
    def _initial_scene_operations(self):
        """
        Initial scene configurations, including frame range, frame rate, and resolution
        """
        # Set file naming format to fileName.frameNumber.ext
        cmds.setAttr("defaultRenderGlobals.animation", True)
        cmds.setAttr("defaultRenderGlobals.putFrameBeforeExt", True)

        # Set color management default setting to ACEScg
        try:
            cmds.colorManagementFileRules("Default",
                                          edit=True,
                                          colorSpace="ACES - ACEScg")
        except:
            cmds.colorManagementFileRules("Default",
                                          edit=True,
                                          colorSpace="ACEScg")

        #Set view transform default setting to Rec.709
        try:
            cmds.colorManagementPrefs(edit=True,
                                      viewTransformName="Rec.709 (ACES)")
        except:
            cmds.colorManagementPrefs(edit=True,
                                      viewTransformName="sRGB (ACES)")

        # Determine current render engine
        curr_renderer = cmds.getAttr('defaultRenderGlobals.currentRenderer')

        if curr_renderer == "arnold":
            # Creates instance of Arnold's defaultSettings node, which is essential
            # for executing Arnold-specific functions without opening the menu
            from mtoa.core import createOptions
            createOptions()

            # # set file naming convention
            # cmds.setAttr("defaultRenderGlobals.imageFilePrefix", "<Scene>_<RenderLayer>/<Scene>_<RenderLayer>", type = "string")
            # set MergeAOVs to True
            cmds.setAttr('defaultArnoldDriver.mergeAOVs', 1)

        elif curr_renderer == "vray":
            cmds.setAttr("vraySettings.animType", 1)
            cmds.setAttr("vraySettings.imageFormatStr", 5)
        else:
            pass
Example #11
0
def RenderView():
    SetupCamera()
    core.createOptions()
    cmds.arnoldRenderView(mode="open")
    cmds.arnoldRenderView()

    # -------- Delete Empty Group
    transforms = cmds.ls(type="transform")
    deleteList = []

    for grp in transforms:
        if cmds.nodeType(grp) == "transform":
            children = cmds.listRelatives(grp, c=True)
            if children == None:
                print "%s, had no children and was deleted" % (grp)
                deleteList.append(grp)

    if len(deleteList) > 0:
        cmds.delete(deleteList)
def aovs_setup(lights):
    """updating render settings AOVs tab"""
    # enable beauty
    createOptions()
    arnold_options = pm.PyNode("defaultArnoldRenderOptions")
    arnold_options.aovMode.set(1)

    # enable default aovs
    default_aovs = [
        "diffuse_direct", "diffuse_indirect", "specular_direct",
        "specular_indirect", "sss_direct", "sss_indirect", "N", "P", "Z",
        "crypto_asset", "crypto_material", "crypto_object", "AO"
    ]
    default_aovs.extend(lights)
    for aov in default_aovs:
        if not aovs.AOVInterface().getAOVNode(aov):
            aovs.AOVInterface().addAOV(aov)

    # enable custom aovs
    # ambient occlusion
    ao_name = "aiAmbientOcclusion"
    if not pm.ls(type=ao_name):
        ao_aov = pm.PyNode("aiAOV_AO")
        ao_shader = pm.shadingNode(ao_name, asShader=1)
        ao_sg = pm.sets(name=ao_name + "SG",
                        empty=1,
                        renderable=1,
                        noSurfaceShader=1)
        ao_shader.outColor >> ao_aov.defaultValue
        ao_shader.outColor >> ao_sg.surfaceShader

    # create light group for each of the lights
    for light in lights:
        shape = pm.PyNode(light).getShape()
        shape.aiAov.set(light)

    # merge aovs
    arnold_driver = pm.PyNode("defaultArnoldDriver")
    arnold_driver.mergeAOVs.set(1)
    arnold_driver.halfPrecision.set(1)
    print ">> aov setup"
    return
Example #13
0
def MaskBuild():

    # sel = cmds.ls(selection=True)

    sets = cmds.ls(sets=True)

    aiMaskSets = []
    for node in sets:
        if node.startswith('aiMask'):
            aiMaskSets.append(node)

    maskDic = {}
    for s in aiMaskSets:
        # find layers
        if ('aiMask' in s) and (('_') not in s):
            maskDic[s] = {}

    for layer in maskDic:
        for s in aiMaskSets:
            if s.startswith(layer + "_"):
                channel = s.split('_')[1]
                print pm.PyNode(s).members()
                maskDic[layer][channel] = pm.PyNode(s).members()

    print maskDic

    if not aiMaskSets:
        cmds.warning('No sets selected!')
        return

    core.createOptions()

    for layer in maskDic:
        aiColor = addIdShader(layer)
        print maskDic[layer]
        for channel in maskDic[layer]:
            for shape in maskDic[layer][channel]:
                # pm_shape = pm.PyNode(shape)
                attr = addColor(shape, layer, channel)

        addAOV(layer, aiColor)
Example #14
0
def MaskBuild():

    # sel = cmds.ls(selection=True)

    sets = cmds.ls(sets=True)

    aiMaskSets = []
    for node in sets:
        if node.startswith('aiMask'):
            aiMaskSets.append(node)

    maskDic = {}
    for s in aiMaskSets:
        # find layers
        if ('aiMask' in s) and (('_') not in s):
            maskDic[s] = {}

    for layer in maskDic:
        for s in aiMaskSets:
            if s.startswith(layer + "_"):
                channel = s.split('_')[1]
                print pm.PyNode(s).members()
                maskDic[layer][channel] = pm.PyNode(s).members()

    print maskDic

    if not aiMaskSets:
        cmds.warning('No sets selected!')
        return

    core.createOptions()

    for layer in maskDic:
        aiColor = addIdShader(layer)
        print maskDic[layer]
        for channel in maskDic[layer]:
            for shape in maskDic[layer][channel]:
                # pm_shape = pm.PyNode(shape)
                attr = addColor(shape, layer, channel)

        addAOV(layer, aiColor)
Example #15
0
def newAOVPrompt(default=''):
    result = pm.cmds.promptDialog(button=['Create', 'Cancel'],
                                  defaultButton='Create',
                                  cancelButton='Cancel',
                                  message='AOV Name',
                                  title='New AOV',
                                  text=default)
    if result == 'Create':
        core.createOptions()
        newAOV = pm.promptDialog(query=True, text=True)#[0:29] # channel names in the exr driver are limited to 29 characterss
        if len(newAOV) > 29:
            oldAOV = newAOV
            newAOV = newAOV[0:29]
            cmds.confirmDialog(message="The name %s is longer than 29 characters, truncated to : %s" % (oldAOV, newAOV))
        if str(newAOV).replace("_","").isalnum():
            return newAOV, aovs.AOVInterface().addAOV(newAOV)
        else:
            print "Invalid AOV Name"
            return None, None
    else:
        print "AOV creation canceled"
        return None, None
Example #16
0
	def loadArnold(self):
		version = mc.about(v = True).split()[0]
		if mc.pluginInfo('mtoa', q=1, l=1):
			print "Arnold is loaded.\n";
		else:
			mc.loadPlugin("C:/solidAngle/mtoadeploy/" + version + "/plug-ins/mtoa.mll")
		if not mn.Node( 'defaultArnoldRenderOptions' ).exists:
			cor.createOptions()
		mc.setAttr("defaultRenderGlobals.currentRenderer", "arnold", type="string")
		mc.setAttr( "defaultViewColorManager.imageColorProfile", 2 )
		mc.setAttr( "defaultArnoldRenderOptions.display_gamma", 1 )
		mc.setAttr( "defaultArnoldRenderOptions.shader_gamma" ,1 )
		mc.setAttr( "defaultArnoldRenderOptions.texture_gamma", 1 )
		mc.setAttr( "defaultArnoldRenderOptions.range_type" ,0 )
		mc.setAttr( "defaultArnoldDriver.halfPrecision", 1 )
		mc.setAttr( "defaultArnoldDriver.preserveLayerName", 1)
		mc.setAttr( "defaultRenderGlobals.extensionPadding", 4)
		mc.setAttr( "defaultRenderGlobals.animation", 1)
		mc.setAttr( "defaultRenderGlobals.outFormatControl", 0 )
		mc.setAttr( "defaultRenderGlobals.putFrameBeforeExt", 1 )
		mc.setAttr( "defaultRenderGlobals.periodInExt", 1)
		mc.setAttr( "defaultArnoldDriver.mergeAOVs", 1 )
		mc.setAttr( "defaultArnoldRenderOptions.use_existing_tiled_textures", 1 )
		"""
# -*- coding: utf-8 -*-
from arnold import *
from mtoa.core import createOptions
createOptions()

import maya.cmds as cmds
import read
reload(read)

fname = cmds.fileDialog2(fm=1, ff='FFVII: Remake .uexp (*.uexp);;')[0]
time = read.readFile(fname)
print "\n\n" + 'Import Time: ' + str(time) + ' seconds' + "\n\n"

cmds.setAttr("defaultArnoldRenderOptions.renderDevice", 1)
cmds.setAttr("defaultArnoldRenderOptions.AASamples", 10)
cmds.setAttr("defaultArnoldRenderOptions.GIDiffuseDepth", 2)
cmds.setAttr("defaultArnoldRenderOptions.GITotalDepth", 16)
cmds.setAttr("defaultArnoldRenderOptions.autoTransparencyDepth", 32)
Example #18
0
def arnoldOpenMtoARenderView():
    core.createOptions()
    cmds.arnoldRenderView(mode="open")
Example #19
0
def arnoldMtoARenderView():
    core.createOptions()
    cmds.arnoldRenderView(cam='cameraShape1')
Example #20
0
def create_arnold_options():
    core.createOptions()

    return
Example #21
0
def MaskBuild():

    sel = cmds.ls(selection=True)

    aiMaskSets = []
    for node in sel:
        if cmds.nodeType(node) == 'objectSet':
            aiMaskSets.append(node)

    if not aiMaskSets:
        cmds.warning('No sets selected!')
        return

    core.createOptions()

    aiColor = cmds.shadingNode('aiUserDataColor', asShader=1)

    cmds.setAttr(aiColor + '.defaultValue', 1, 1, 1, typ='double3')

    for aiSet in xrange(0, len(aiMaskSets), 3):

        tSwitch = cmds.shadingNode('tripleShadingSwitch', au=1)
        cmds.setAttr(tSwitch + '.default', 0, 0, 0, typ='double3')

        aiUshader = cmds.shadingNode('aiUtility', asShader=1)
        cmds.setAttr(aiUshader + '.shadeMode', 2)
        cmds.connectAttr(tSwitch + '.output', aiUshader + '.color', f=1)

        for obj in cmds.listRelatives(cmds.sets(aiSet, q=1), pa=1):
            inpt = cmds.getAttr(tSwitch + '.input', s=1)
            if cmds.nodeType(obj) == 'mesh':
                cmds.connectAttr(obj + '.instObjGroups[0]',
                                 tSwitch + '.input[' + str(inpt) + '].inShape',
                                 f=1)
                cmds.connectAttr(aiColor + '.outColor',
                                 tSwitch + '.input[' + str(inpt) +
                                 '].inTriple',
                                 f=1)

        #AOV
        aovListSize = cmds.getAttr('defaultArnoldRenderOptions.aovList', s=1)

        customAOV = cmds.createNode('aiAOV',
                                    n='aiAOV_rgbMask',
                                    skipSelect=True)
        cmds.setAttr(customAOV + '.name', aiSet, type='string')
        cmds.connectAttr(customAOV + '.message',
                         'defaultArnoldRenderOptions.aovList[' +
                         str(aovListSize) + ']',
                         f=1)

        cmds.connectAttr('defaultArnoldDriver.message',
                         customAOV + '.outputs[0].driver',
                         f=1)
        cmds.connectAttr('defaultArnoldFilter.message',
                         customAOV + '.outputs[0].filter',
                         f=1)

        # connect to default shader
        cmds.connectAttr(aiUshader + '.outColor',
                         customAOV + '.defaultValue',
                         f=1)
Example #22
0
def arnoldRender(width, height, doShadows, doGlowPass, camera, options):
    # Make sure the aiOptions node exists
    core.createOptions()
    cmds.arnoldRender(cam=camera, w=width, h=height)
Example #23
0
def arnoldIprStart(editor, resolutionX, resolutionY, camera):
    # Make sure the aiOptions node exists
    core.createOptions()
    cmds.arnoldIpr(cam=camera, w=resolutionX, h=resolutionY, mode="start")
def create_layers():
    if not pm.objExists('objs'):
        pm.confirmDialog(t='confirm',
                         m='No objs grp, please put all objects under it!',
                         b=['ok'])
        sys.exit('')

    # save origin
    current_file = pm.sceneName()
    if 'original' in current_file.basename():
        pm.saveFile()
    else:
        origin_file = current_file.dirname() + '/' + current_file.basename(
        ).stripext() + '_original' + current_file.ext
        pm.saveAs(origin_file)

    rs_ins = rs.instance()
    rs_ins.getDefaultRenderLayer().setRenderable(0)
    ar.createOptions()
    pm.setAttr("defaultArnoldDriver.ai_translator", "tif", type="string")
    # pm.setAttr('defaultArnoldDriver.mergeAOVs', 0)
    pm.setAttr('defaultRenderGlobals.imageFilePrefix',
               '<Scene>/<RenderLayer>_<RenderPass>')

    aovs.AOVInterface().addAOV('ao', aovType='rgba')
    ao = pm.createNode('aiAmbientOcclusion')
    ao.outColor >> pm.PyNode('aiAOV_ao').defaultValue

    asm = pm.createNode('aiShadowMatte')

    # rs layer
    for obj in pm.PyNode('objs').getChildren():
        # if has a rayswitch child
        flag = 1 if obj.getChildren(typ='transform') else 0

        # beauty with shadow
        print obj.name(), obj.type()

        obj.getShape().aiSubdivType.set(1)
        obj.getShape().aiSubdivIterations.set(2)

        obj.getShape().primaryVisibility.set(1)
        obj.getShape().castsShadows.set(1)
        obj.getShape().aiVisibleInDiffuseReflection.set(1)
        obj.getShape().aiVisibleInSpecularReflection.set(1)
        obj.getShape().aiVisibleInDiffuseTransmission.set(1)
        obj.getShape().aiVisibleInSpecularTransmission.set(1)
        obj.getShape().aiVisibleInVolume.set(1)
        obj.getShape().aiSelfShadows.set(1)

        rsl = rs_ins.createRenderLayer(obj.name() + '_color')

        co1 = rsl.createCollection('co1_' + obj.name())
        co1.getSelector().setPattern('*')

        skydomelight = pm.ls(typ='aiSkyDomeLight')[0]
        co1_skydome = co1.createCollection('co1_skydome_' + obj.name())
        co1_skydome.getSelector().setPattern(skydomelight)
        co1_skydome.getSelector().setFilterType(4)
        ov_skydome = co1_skydome.createOverride('ov_skydome_' + obj.name(),
                                                absOverride)
        ov_skydome.finalize('aiCastShadows')
        ov_skydome.setAttrValue(1)

        co2 = co1.createCollection('co2_' + obj.name())
        co2.getSelector().setPattern('objs')

        co3 = co2.createCollection('co3_' + obj.name())
        co3.getSelector().setFilterType(2)
        other_shapes = [i for i in pm.PyNode('objs').getChildren() if i != obj]
        other_shapes_name = ', '.join(
            [i.getShape().name() for i in other_shapes])
        co3.getSelector().setPattern(other_shapes_name)
        ov1 = co3.createOverride('ov1_' + obj.name(), absOverride)
        ov1.finalize('primaryVisibility')
        ov1.setAttrValue(0)
        ov2 = co3.createOverride('ov2_' + obj.name(), absOverride)
        ov2.finalize('castsShadows')
        ov2.setAttrValue(0)

        co4 = co2.createCollection('co4_' + obj.name())
        co4.getSelector().setFilterType(2)
        co4.getSelector().setPattern(obj.getShape().name())
        ov3 = co4.createOverride('ov3_' + obj.name(), absOverride)
        ov3.finalize('aiSelfShadows')
        ov3.setAttrValue(1)

        # shadow
        rsl = rs_ins.createRenderLayer(obj.name() + '_shadow')

        aov = rsl.aovCollectionInstance()
        sub_colle = coll.create(obj.name() + '_ao',
                                coll.AOVChildCollection.kTypeId,
                                aovName='ao')
        aov.appendChild(sub_colle)
        override = sub_colle.createAbsoluteOverride('aiAOV_ao', 'enabled')
        override.setAttrValue(0)
        override.setName(obj.name() + '_ov_ao')

        co5 = rsl.createCollection('co5_' + obj.name())
        co5.getSelector().setPattern('*')

        co5_skydome = co5.createCollection('co5_skydome_' + obj.name())
        co5_skydome.getSelector().setPattern(skydomelight)
        co5_skydome.getSelector().setFilterType(4)
        ov5_skydome = co5_skydome.createOverride('ov5_skydome_' + obj.name(),
                                                 absOverride)
        ov5_skydome.finalize('aiCastShadows')
        ov5_skydome.setAttrValue(0)

        co6 = co5.createCollection('co6_' + obj.name())
        co6.getSelector().setPattern('objs')
        co7 = co6.createCollection('co7_' + obj.name())
        co7.getSelector().setFilterType(2)
        co7.getSelector().setPattern(obj.getShape().name())
        ov4 = co7.createOverride('ov4_' + obj.name(), absOverride)
        ov4.finalize('primaryVisibility')
        ov4.setAttrValue(0)

        co8 = co6.createCollection('co8_' + obj.name())
        co8.getSelector().setFilterType(2)
        co8.getSelector().setPattern(other_shapes_name)
        # co9 = co8.createCollection('co9_'+obj.name())
        # co9.getSelector().setFilterType(5)
        # co9.getSelector().setPattern('*')
        ov6 = co8.createOverride('ov6_' + obj.name(), shaderOverride)
        ov6.setShader(asm.name())
        ov7 = co8.createOverride('ov7_' + obj.name(), absOverride)
        ov7.finalize('castsShadows')
        ov7.setAttrValue(0)
        ov8 = co8.createOverride('ov8_' + obj.name(), absOverride)
        ov8.finalize('aiSelfShadows')
        ov8.setAttrValue(0)

        if flag:
            for ii in obj.getChildren(typ='transform'):
                ii.getShape().aiSubdivType.set(1)
                ii.getShape().aiSubdivIterations.set(2)

                ii.getShape().primaryVisibility.set(0)
                ii.getShape().castsShadows.set(0)
                ii.getShape().aiVisibleInDiffuseReflection.set(0)
                ii.getShape().aiVisibleInSpecularReflection.set(0)
                ii.getShape().aiVisibleInDiffuseTransmission.set(0)
                ii.getShape().aiVisibleInSpecularTransmission.set(0)
                ii.getShape().aiVisibleInVolume.set(0)
                ii.getShape().aiSelfShadows.set(0)

                ii.getShape().aiMatte.set(1)

            coa = co2.createCollection('coa_' + obj.name())
            coa.getSelector().setFilterType(2)
            rayswitch_names = ', '.join([
                i.getShape().name() for i in obj.getChildren(typ='transform')
            ])
            coa.getSelector().setPattern(rayswitch_names)
            ova = coa.createOverride('ova_' + obj.name(), absOverride)
            ova.finalize('primaryVisibility')
            ova.setAttrValue(1)

            cob = co6.createCollection('cob_' + obj.name())
            cob.getSelector().setFilterType(2)
            cob.getSelector().setPattern(rayswitch_names)
            ovb = cob.createOverride('ovb_' + obj.name(), absOverride)
            ovb.finalize('primaryVisibility')
            ovb.setAttrValue(1)

    rsl = rs_ins.createRenderLayer('all_objs')
    co = rsl.createCollection('co_all')
    co.getSelector().setPattern('*')

    # save after script
    modify_file = current_file.dirname() + '/' + current_file.basename(
    ).stripext() + '_modify' + current_file.ext
    pm.saveAs(modify_file)
Example #25
0
def createArnoldRendererGlobalsTab():

    # Make sure the aiOptions node exists
    core.createOptions()

    parentForm = pm.setParent(query=True)

    pm.setUITemplate("attributeEditorTemplate", pushTemplate=True)
    pm.scrollLayout("arnoldGlobalsScrollLayout", horizontalScrollBarThickness=0)
    pm.columnLayout("arnoldTabColumn", adjustableColumn=True)

    # Sampling
    #
    pm.frameLayout("arnoldSamplingSettings", label="Sampling", cll=True, cl=0)
    createArnoldSamplingSettings()
    pm.setParent("..")

    # Ray depth
    #
    pm.frameLayout("arnoldRayDepthSettings", label="Ray Depth", cll=True, cl=1)
    createArnoldRayDepthSettings()
    pm.setParent("..")

    # Environment
    #
    pm.frameLayout("arnoldEnvironmentSettings", label="Environment", cll=True, cl=1)
    createArnoldEnvironmentSettings()
    pm.setParent("..")

    # Motion Blur
    #
    pm.frameLayout("arnoldMotionBlurSettings", label="Motion Blur", cll=True, cl=1)
    createArnoldMotionBlurSettings()
    pm.setParent("..")

    # Light Linking
    #
    pm.frameLayout("arnoldLightSettings", label="Lights", cll=True, cl=1)
    createArnoldLightSettings()
    pm.setParent("..")

    # Gamma correction
    #
    pm.frameLayout("arnoldGammaSettings", label="Gamma Correction", cll=True, cl=1)
    createArnoldGammaSettings()
    pm.setParent("..")

    # Gamma correction
    #
    pm.frameLayout("arnoldTextureSettings", label="Textures", cll=True, cl=1)
    createArnoldTextureSettings()
    pm.setParent("..")

    pm.setParent("..")

    pm.formLayout(
        parentForm,
        edit=True,
        af=[
            ("arnoldGlobalsScrollLayout", "top", 0),
            ("arnoldGlobalsScrollLayout", "bottom", 0),
            ("arnoldGlobalsScrollLayout", "left", 0),
            ("arnoldGlobalsScrollLayout", "right", 0),
        ],
    )

    pm.setParent(parentForm)

    updateArnoldRendererGlobalsTab()