def makeRenderFacial(makeElements = elements, force = True) : 
	info, missing = checkElements()
	name = renderLayerTextureName

	# if layeredTexture exists 
	if mc.objExists(name) : 
		# instance 
		ltNode = mNode.layeredTexture(name)

		# clear matte channel
		ltNode.cleanAllMatte()

	# if not exists 
	else : 
		# instance new layeredTexture
		ltNode = mNode.layeredTexture()
		ltNode.setName(name)

	# add texture to list
	for each in reversed(makeElements) : 

		# if elements exists, continue 
		if each in info.keys() : 
			filepath = info[each]['path']
			mode = elementMaps[each]['mode']
			nodeAttr = elementMaps[each]['attr']

			addLayerTexture(filepath, ltNode, mode, nodeAttr, True, True)


	return ltNode
def addLayerTexture(filepath, nodeName, mode, nodeAttr, addCtrl = False, force = False) : 
	# if path exists 
	if os.path.exists(filepath) : 
		ltNode = mNode.layeredTexture(nodeName)

		# subdir as node name 
		filepath = filepath.replace('\\', '/')
		name = filepath.split('/')[-2]
		nodeName = '%s_rFile' % name
		plcName = '%s_rPlc' % name

		state = True 

		if mc.objExists(nodeName) : 
			state = force

		if state : 

			# create file node 
			fileNode = mNode.fileNode()
			fileNode.setName(nodeName)
			fileNode.setFileName(filepath)

			# turn off filter 
			fileNode.setFilter(0)

			# find last index 
			indexs = ltNode.listIndexs()
			lastIndex = 1

			if indexs : 
				lastIndex = indexs[-1] + 1 

				# remove matte color if exists 
				if 0 in indexs : 
					if ltNode.isMatteColor(0) : 
						ltNode.removeTexture(0)

			ltNode.addTexture(fileNode, lastIndex)
			ltNode.setBlendMode(lastIndex, mode)

			# add placement 
			plcNode = mNode.placementNode()
			plcNode.setName(plcName)
			plcNode.connectFileNode(fileNode)

			if addCtrl : 
				addController(name, fileNode, plcNode, nodeAttr)
def makeAnimFacial(renderTextureNode) : 
	# instance renderNode
	renderNode = mNode.layeredTexture(renderTextureNode)
	nodes = renderNode.listTextures()
	indexs = renderNode.listIndexs()

	# create anim render layer
	if mc.objExists(animLayerTextureName) : 
		mc.delete(animLayerTextureName) 

	ltNode = mNode.layeredTexture()
	ltNode.setName(animLayerTextureName)

	# clear all aFile nodes 
	mc.delete(mc.ls('*aFile'))

	# loop each connected node 
	index = 0 
	ii = 0 

	for node in nodes : 
		# instance file node 
		fileNode = mNode.fileNode(node)
		filePath = fileNode.getFileName()
		files = getFileSequences(filePath)

		# find connection to image sequences
		switchAttr = mc.listConnections('%s.frameExtension' % fileNode, p = True)

		# find index 
		blendMode = renderNode.getBlendMode(indexs[ii])

		# find placement and instance 
		plc = fileNode.findPlacement()

		if plc : 
			plcNode = mNode.placementNode(plc[0])

		else : 
			plcNode = mNode.placementNode()

		# loop each files in node
		i = 0 

		for eachFile in files : 
			num = findNum(eachFile)
			fileNodeName = '%s_%s_aFile' % (node, num)
			cndNodeName = '%s_%s_aCnd' % (node, num)
			filePath = eachFile.replace(res, animRes) 

			# create file node 
			fileNode = mNode.fileNode()
			fileNode.setName(fileNodeName)
			fileNode.setFileName(filePath)

			# turn off filter 
			fileNode.setFilter(0)

			# add to layeredTexture 
			ltNode.addTexture(fileNode, index)
			ltNode.setBlendMode(index, blendMode)

			# connected placement 
			plcNode.connectFileNode(fileNode)

			# connect switch attr 
			if switchAttr : 
				cndNode = mNode.condition()
				cndNode.setName(cndNodeName)
				cndNode.connectFirstTerm(switchAttr[0])
				cndNode.setSecondTerm(int(num))
				cndNode.setColorIfTrue(1, 1, 1)
				cndNode.setColorIfFalse(0, 0, 0)

				# link to visible state of layeredTexture 
				targetAttr = '%s.inputs[%s]isVisible' % (ltNode, index)
				cndNode.connectOutput('red', targetAttr)

				i += 1 

			index += 1 

		ii += 1 

	return ltNode