def execute(self, context): # Add simple plane bpy.ops.mesh.primitive_plane_add() ob = context.active_object ob.name = "VRayInfinitePlane" # Add V-Ray node tree VRayObject = ob.vray nt = bpy.data.node_groups.new(ob.name, type='VRayNodeTreeObject') nt.use_fake_user = True outputNode = nt.nodes.new('VRayNodeObjectOutput') planeGeometry = nt.nodes.new('VRayNodeGeomPlane') blenderMaterial = nt.nodes.new('VRayNodeBlenderOutputMaterial') blenderMaterial.location.x = outputNode.location.x - 200 blenderMaterial.location.y = outputNode.location.y + 30 planeGeometry.location.x = outputNode.location.x - 200 planeGeometry.location.y = outputNode.location.y - 150 nt.links.new(blenderMaterial.outputs['Material'], outputNode.inputs['Material']) nt.links.new(planeGeometry.outputs['Geometry'], outputNode.inputs['Geometry']) NodesTools.deselectNodes(nt) VRayObject.ntree = nt return {'FINISHED'}
def ConvertNodeMaterial(scene, ob, ma): debug.PrintInfo("Converting node material: %s" % ma.name) materialNode = None maNtree = ma.node_tree nt = _createVRayTree(ma.name, 'Material') ntOutput = _createVRayNode(nt, 'OutputMaterial') ntMaterial = _createVRayNode(nt, 'MtlSingleBRDF') _connectNodes(nt, ntMaterial, 'Material', ntOutput, 'Material') maNtreeOutput = NodesUtils.GetNodeByType(maNtree, 'ShaderNodeOutputMaterial') maShader = NodesUtils.GetConnectedNode(maNtree, maNtreeOutput.inputs['Surface']) vrayNode = ConvertNode(maNtree, maShader, nt) if vrayNode: _connectNodes(nt, vrayNode, 'BRDF', ntMaterial, 'BRDF') NodesTools.rearrangeTree(nt, ntOutput) NodesTools.deselectNodes(nt) ma.vray.ntree = nt return ntMaterial
def CreateProxyNodetree(ob, proxyFilepath): VRayObject = ob.vray if VRayObject.ntree: return "Node tree already exists!" nt = bpy.data.node_groups.new(ob.name, type='VRayNodeTreeObject') nt.use_fake_user = True outputNode = nt.nodes.new('VRayNodeObjectOutput') proxyGeometry = nt.nodes.new('VRayNodeGeomMeshFile') blenderMaterial = nt.nodes.new('VRayNodeBlenderOutputMaterial') blenderMaterial.location.x = outputNode.location.x - 200 blenderMaterial.location.y = outputNode.location.y + 30 proxyGeometry.location.x = outputNode.location.x - 200 proxyGeometry.location.y = outputNode.location.y - 150 nt.links.new(blenderMaterial.outputs['Material'], outputNode.inputs['Material']) nt.links.new(proxyGeometry.outputs['Geometry'], outputNode.inputs['Geometry']) NodesTools.deselectNodes(nt) proxyGeometry.GeomMeshFile.file = proxyFilepath VRayObject.ntree = nt
def CreateProxyNodetree(ob, proxyFilepath, isRelative=False): VRayObject = ob.vray if VRayObject.ntree: return "Node tree already exists!" nt = bpy.data.node_groups.new(ob.name, type='VRayNodeTreeObject') nt.use_fake_user = True outputNode = nt.nodes.new('VRayNodeObjectOutput') proxyGeometry = nt.nodes.new('VRayNodeGeomMeshFile') blenderMaterial = nt.nodes.new('VRayNodeBlenderOutputMaterial') blenderMaterial.location.x = outputNode.location.x - 200 blenderMaterial.location.y = outputNode.location.y + 30 proxyGeometry.location.x = outputNode.location.x - 200 proxyGeometry.location.y = outputNode.location.y - 150 nt.links.new(blenderMaterial.outputs['Material'], outputNode.inputs['Material']) nt.links.new(proxyGeometry.outputs['Geometry'], outputNode.inputs['Geometry']) NodesTools.deselectNodes(nt) proxyGeometry.GeomMeshFile.file = bpy.path.relpath( proxyFilepath) if isRelative and bpy.data.filepath else proxyFilepath VRayObject.ntree = nt
def _execute(self, context, vrsceneDict): space = context.space_data ntree = space.edit_tree # Deselect before import NodesTools.deselectNodes(ntree) # Get fake asset node assetDesc = NodesImport.getPluginByType(vrsceneDict, "Asset") assetType = assetDesc['Name'] # Import template lastNode = None if assetType == 'Material': maName = assetDesc['Attributes']['material'] maDesc = NodesImport.getPluginByName(vrsceneDict, maName) maNode = NodesImport.createNode(ntree, None, vrsceneDict, maDesc) # NOTE: Depends on how user saves the preset if 'Material' not in maNode.outputs: lastNode = maNode else: outputNode = ntree.nodes.new('VRayNodeOutputMaterial') ntree.links.new(maNode.outputs['Material'], outputNode.inputs['Material']) lastNode = outputNode elif assetType == 'Texture': texName = assetDesc['Attributes']['texture'] texDesc = NodesImport.getPluginByName(vrsceneDict, texName) lastNode = NodesImport.createNode(ntree, None, vrsceneDict, texDesc) elif assetType == 'Channel': chanNames = assetDesc['Attributes']['channel'] if len(chanNames): channContainer = ntree.nodes.new('VRayNodeRenderChannels') for i,chanName in enumerate(reversed(chanNames)): chanSockName = "Channel %i" % i NodesSockets.AddInput(channContainer, 'VRaySocketRenderChannel', chanSockName) chanDesc = NodesImport.getPluginByName(vrsceneDict, chanName) chanNode = NodesImport.createNode(ntree, None, vrsceneDict, chanDesc) ntree.links.new(chanNode.outputs['Channel'], channContainer.inputs[chanSockName]) lastNode = channContainer if lastNode: NodesTools.rearrangeTree(ntree, lastNode) return {'FINISHED'}
def _execute(self, context, vrsceneDict): space = context.space_data ntree = space.edit_tree # Deselect before import NodesTools.deselectNodes(ntree) # Get fake asset node assetDesc = NodesImport.getPluginByType(vrsceneDict, "Asset") assetType = assetDesc['Name'] # Import template lastNode = None if assetType == 'Material': maName = assetDesc['Attributes']['material'] maDesc = NodesImport.getPluginByName(vrsceneDict, maName) maNode = NodesImport.createNode(ntree, None, vrsceneDict, maDesc) # NOTE: Depends on how user saves the preset if 'Material' not in maNode.outputs: lastNode = maNode else: outputNode = ntree.nodes.new('VRayNodeOutputMaterial') ntree.links.new(maNode.outputs['Material'], outputNode.inputs['Material']) lastNode = outputNode elif assetType == 'Texture': texName = assetDesc['Attributes']['texture'] texDesc = NodesImport.getPluginByName(vrsceneDict, texName) lastNode = NodesImport.createNode(ntree, None, vrsceneDict, texDesc) if lastNode: NodesTools.rearrangeTree(ntree, lastNode) return {'FINISHED'}
def ImportMaterialWithDisplacement(context, filePath, use_fake_user=True): debug.PrintInfo('Importing materials from "%s"' % filePath) vrsceneDict = {} if filePath.endswith(".vrscene"): vrsceneDict = ParseVrscene(filePath) else: vrsceneDict = ParseVrmat(filePath) nodeNames = [] for pluginDesc in vrsceneDict: pluginID = pluginDesc['ID'] pluginName = pluginDesc['Name'] if pluginID == 'Node': nodeNames.append(pluginName) for nodeName in nodeNames: debug.PrintInfo("Importing material from Node: %s" % nodeName) nodePluginDesc = NodesImport.getPluginByName(vrsceneDict, nodeName) # Import material # maName = nodePluginDesc['Attributes']['material'] if maName in bpy.data.node_groups: continue maPluginDesc = NodesImport.getPluginByName(vrsceneDict, maName) if not maPluginDesc: continue maNtree = bpy.data.node_groups.new(maName, type='VRayNodeTreeMaterial') maNtree.use_fake_user = True maOutputNode = maNtree.nodes.new('VRayNodeOutputMaterial') maNode = NodesImport.createNode(maNtree, maOutputNode, vrsceneDict, maPluginDesc) maNtree.links.new(maNode.outputs['Material'], maOutputNode.inputs['Material']) NodesTools.rearrangeTree(maNtree, maOutputNode) # Check geometry for displacement # geomName = nodePluginDesc['Attributes']['geometry'] geomPluginDesc = NodesImport.getPluginByName(vrsceneDict, geomName) if geomPluginDesc and geomPluginDesc['ID'] == 'GeomDisplacedMesh': colorTexName = geomPluginDesc['Attributes'].get( "displacement_tex_color") floatTexName = geomPluginDesc['Attributes'].get( "displacement_tex_float") if colorTexName or floatTexName: # Create node tree with displace name dispNtree = bpy.data.node_groups.new( geomPluginDesc['Name'], type='VRayNodeTreeMaterial') dispNtree.use_fake_user = True # Add group output to displace tree dispGroupOutput = dispNtree.nodes.new('NodeGroupOutput') # Import texture nodes colorTexNode = NodesImport.FindAndCreateNode( vrsceneDict, colorTexName, dispNtree, dispGroupOutput) floatTexNode = NodesImport.FindAndCreateNode( vrsceneDict, floatTexName, dispNtree, dispGroupOutput) # Add/connect output sockets if colorTexName: dispNtree.outputs.new('VRaySocketColor', 'Color') dispNtree.links.new(colorTexNode.outputs['Output'], dispGroupOutput.inputs['Color']) if floatTexName: dispNtree.outputs.new('VRaySocketFloat', 'Float') dispNtree.links.new(floatTexNode.outputs['Output'], dispGroupOutput.inputs['Float']) NodesTools.rearrangeTree(dispNtree, dispGroupOutput) NodesTools.deselectNodes(dispNtree) # Create a group node in current material tree # to show user that we have displacement dispGroupNode = maNtree.nodes.new('ShaderNodeGroup') dispGroupNode.node_tree = dispNtree dispGroupNode.location.x = 0 dispGroupNode.location.y = 100 # Finally create a material CreateMaterial(maName, maNtree, use_fake_user) NodesTools.deselectNodes(maNtree) return {'FINISHED'}
def ImportMaterials(context, filePath, baseMaterial, use_fake_user=True): debug.PrintInfo('Importing materials from "%s"' % filePath) vrsceneDict = {} if filePath.endswith(".vrscene"): vrsceneDict = ParseVrscene(filePath) else: vrsceneDict = ParseVrmat(filePath) MaterialTypeFilter = { 'STANDARD': { 'MtlSingleBRDF', 'MtlVRmat', 'MtlDoubleSided', 'MtlGLSL', 'MtlLayeredBRDF', 'MtlDiffuse', 'MtlBump', 'Mtl2Sided', }, 'MULTI': {'MtlMulti'}, 'WRAPPED': { 'MtlWrapper', 'MtlWrapperMaya', 'MayaMtlMatte', 'MtlMaterialID', 'MtlMayaRamp', 'MtlObjBBox', 'MtlOverride', 'MtlRenderStats', 'MtlRoundEdges', 'MtlStreakFade', }, } # Collect material names based on selected # base material type # materialNames = [] for pluginDesc in vrsceneDict: pluginID = pluginDesc['ID'] pluginName = pluginDesc['Name'] if pluginID in MaterialTypeFilter[baseMaterial]: materialNames.append(pluginName) for maName in materialNames: debug.PrintInfo("Importing material: %s" % maName) pluginDesc = NodesImport.getPluginByName(vrsceneDict, maName) ntree = bpy.data.node_groups.new(maName, type='VRayNodeTreeMaterial') ntree.use_fake_user = True outputNode = ntree.nodes.new('VRayNodeOutputMaterial') maNode = NodesImport.createNode(ntree, outputNode, vrsceneDict, pluginDesc) ntree.links.new(maNode.outputs['Material'], outputNode.inputs['Material']) NodesTools.rearrangeTree(ntree, outputNode) NodesTools.deselectNodes(ntree) # Finally create a material CreateMaterial(maName, ntree, use_fake_user) return {'FINISHED'}
def ConvertMaterial(scene, ob, ma, textures): VRayMaterial = ma.vray VRayConverter = scene.vray.VRayConverter # This is the last node of the material # NOT the output, but the last Mtl node materialNode = None if VRayMaterial.ntree: outputNode = NodesUtils.GetNodeByType(VRayMaterial.ntree, 'VRayNodeOutputMaterial') materialNode = NodesUtils.GetConnectedNode(VRayMaterial.ntree, outputNode.inputs['Material']) else: if ma.node_tree: if VRayConverter.convert_from == 'CYCLES': return ConvertNodeMaterial(scene, ob, ma) return None debug.PrintInfo("Converting material: %s" % ma.name) nt = _createVRayTree(ma.name, 'Material') outputNode = _createVRayNode(nt, 'OutputMaterial') materialTop = _createVRayNode(nt, 'MtlSingleBRDF') brdfTo = materialTop mainBRDF = None if VRayMaterial.round_edges: mtlRoundEdges = _createVRayNode(nt, 'MtlRoundEdges') mtlRoundEdges.inputs['Radius'].value = VRayMaterial.radius _connectNodes(nt, materialTop, 'Material', mtlRoundEdges, 'Base Mtl') materialTop = mtlRoundEdges if VRayMaterial.material_id_number: mtlMaterialID = _createVRayNode(nt, 'MtlMaterialID') mtlMaterialID.MtlMaterialID.material_id_number = VRayMaterial.material_id_number mtlMaterialID.inputs['Material Id Color'].value = VRayMaterial.material_id_color _connectNodes(nt, materialTop, 'Material', mtlMaterialID, 'Base Mtl') materialTop = mtlMaterialID if VRayMaterial.Mtl2Sided.use: mtl2Sided = _createVRayNode(nt, 'Mtl2Sided') mtl2Sided.Mtl2Sided.force_1sided = VRayMaterial.Mtl2Sided.force_1sided mtl2Sided.inputs['Translucency'].value = [VRayMaterial.Mtl2Sided.translucency_slider]*3 backMat = None if VRayMaterial.Mtl2Sided.back: backMaName = VRayMaterial.Mtl2Sided.back if backMaName in bpy.data.materials: backMa = bpy.data.materials[backMaName] backTex = ProcessTextures(backMa) ConvertMaterial(scene, ob, backMa, backTex) backMat = _createGroupMaterial(nt, backMa) _connectNodes(nt, materialTop, 'Material', mtl2Sided, 'Front') if backMat: _connectNodes(nt, backMat, 'Material', mtl2Sided, 'Back') else: _connectNodes(nt, materialTop, 'Material', mtl2Sided, 'Back') materialTop = mtl2Sided if VRayMaterial.MtlOverride.use: pass for ovrName in {'MtlWrapper', 'MtlRenderStats'}: ovrPropGroup = getattr(VRayMaterial, ovrName) ovrUse = getattr(ovrPropGroup, 'use') if not ovrUse: continue debug.PrintInfo(" Found override: %s" % ovrName) ovrNode = _createVRayNode(nt, ovrName) _connectNodes(nt, materialTop, 'Material', ovrNode, OverrideInputSocket[ovrName]) materialTop = ovrNode # Connect last material to the output materialNode = materialTop _connectNodes(nt, materialTop, 'Material', outputNode, 'Material') # BRDFs # if 'normal' in textures: norTex = _getTextureFromTextures(textures, 'normal') mainBRDF = _createVRayNode(nt, 'BRDFBump') mainBRDF.inputs['Bump Amount Texture'].value = _getBumpAmount(ma) bumpTexNode = norTex.createNode(nt) _connectNodes(nt, bumpTexNode, 'Color', mainBRDF, 'Color Texture' ) _connectNodes(nt, bumpTexNode, 'Out Intensity', mainBRDF, 'Float Texture' ) # Finally generate main BRDF node and connect top brdf # if needed brdfType = VRayMaterial.type baseBRDF = _createVRayNode(nt, brdfType) oldPropGroup = getattr(VRayMaterial, brdfType) TransferProperties(baseBRDF, brdfType, oldPropGroup) # Manual tweaks if brdfType == 'BRDFVRayMtl': baseBRDF.inputs['Fog Color'].value = VRayMaterial.BRDFVRayMtl.fog_color CreateTextureNodes(nt, baseBRDF, textures) if brdfType == 'BRDFVRayMtl': if 'reflect' not in textures: baseBRDF.inputs['Reflect'].value = oldPropGroup.reflect_color if 'refract' not in textures: baseBRDF.inputs['Refract'].value = oldPropGroup.refract_color baseBRDF.inputs['Fog Color'].value = oldPropGroup.fog_color if not mainBRDF: mainBRDF = baseBRDF else: _connectNodes(nt, baseBRDF, 'BRDF', mainBRDF, 'Base Brdf') # Connect last BRDF to the last material _connectNodes(nt, mainBRDF, 'BRDF', brdfTo, 'BRDF') NodesTools.rearrangeTree(nt, outputNode) NodesTools.deselectNodes(nt) VRayMaterial.ntree = nt return materialNode
def ImportMaterialWithDisplacement(context, filePath, use_fake_user=True): debug.PrintInfo('Importing materials from "%s"' % filePath) vrsceneDict = {} if filePath.endswith(".vrscene"): vrsceneDict = ParseVrscene(filePath) else: vrsceneDict = ParseVrmat(filePath) nodeNames = [] for pluginDesc in vrsceneDict: pluginID = pluginDesc['ID'] pluginName = pluginDesc['Name'] if pluginID == 'Node': nodeNames.append(pluginName) for nodeName in nodeNames: debug.PrintInfo("Importing material from Node: %s" % nodeName) nodePluginDesc = NodesImport.getPluginByName(vrsceneDict, nodeName) # Import material # maName = nodePluginDesc['Attributes']['material'] if maName in bpy.data.node_groups: continue maPluginDesc = NodesImport.getPluginByName(vrsceneDict, maName) if not maPluginDesc: continue maNtree = bpy.data.node_groups.new(maName, type='VRayNodeTreeMaterial') maNtree.use_fake_user = True maOutputNode = maNtree.nodes.new('VRayNodeOutputMaterial') maNode = NodesImport.createNode(maNtree, maOutputNode, vrsceneDict, maPluginDesc) maNtree.links.new( maNode.outputs['Material'], maOutputNode.inputs['Material'] ) NodesTools.rearrangeTree(maNtree, maOutputNode) # Check geometry for displacement # geomName = nodePluginDesc['Attributes']['geometry'] geomPluginDesc = NodesImport.getPluginByName(vrsceneDict, geomName) if geomPluginDesc and geomPluginDesc['ID'] == 'GeomDisplacedMesh': colorTexName = geomPluginDesc['Attributes'].get("displacement_tex_color") floatTexName = geomPluginDesc['Attributes'].get("displacement_tex_float") if colorTexName or floatTexName: # Create node tree with displace name dispNtree = bpy.data.node_groups.new(geomPluginDesc['Name'], type='VRayNodeTreeMaterial') dispNtree.use_fake_user = True # Add group output to displace tree dispGroupOutput = dispNtree.nodes.new('NodeGroupOutput') # Import texture nodes colorTexNode = NodesImport.FindAndCreateNode(vrsceneDict, colorTexName, dispNtree, dispGroupOutput) floatTexNode = NodesImport.FindAndCreateNode(vrsceneDict, floatTexName, dispNtree, dispGroupOutput) # Add/connect output sockets if colorTexName: dispNtree.outputs.new('VRaySocketColor', 'Color') dispNtree.links.new( colorTexNode.outputs['Output'], dispGroupOutput.inputs['Color'] ) if floatTexName: dispNtree.outputs.new('VRaySocketFloat', 'Float') dispNtree.links.new( floatTexNode.outputs['Output'], dispGroupOutput.inputs['Float'] ) NodesTools.rearrangeTree(dispNtree, dispGroupOutput) NodesTools.deselectNodes(dispNtree) # Create a group node in current material tree # to show user that we have displacement dispGroupNode = maNtree.nodes.new('ShaderNodeGroup') dispGroupNode.node_tree = dispNtree dispGroupNode.location.x = 0 dispGroupNode.location.y = 100 # Finally create a material CreateMaterial(maName, maNtree, use_fake_user) NodesTools.deselectNodes(maNtree) return {'FINISHED'}
def ImportMaterials(context, filePath, baseMaterial, use_fake_user=True): debug.PrintInfo('Importing materials from "%s"' % filePath) vrsceneDict = {} if filePath.endswith(".vrscene"): vrsceneDict = ParseVrscene(filePath) else: vrsceneDict = ParseVrmat(filePath) MaterialTypeFilter = { 'STANDARD' : { 'MtlSingleBRDF', 'MtlVRmat', 'MtlDoubleSided', 'MtlGLSL', 'MtlLayeredBRDF', 'MtlDiffuse', 'MtlBump', 'Mtl2Sided', }, 'MULTI' : { 'MtlMulti' }, 'WRAPPED' : { 'MtlWrapper', 'MtlWrapperMaya', 'MayaMtlMatte', 'MtlMaterialID', 'MtlMayaRamp', 'MtlObjBBox', 'MtlOverride', 'MtlRenderStats', 'MtlRoundEdges', 'MtlStreakFade', }, } # Collect material names based on selected # base material type # materialNames = [] for pluginDesc in vrsceneDict: pluginID = pluginDesc['ID'] pluginName = pluginDesc['Name'] if pluginID in MaterialTypeFilter[baseMaterial]: materialNames.append(pluginName) for maName in materialNames: debug.PrintInfo("Importing material: %s" % maName) pluginDesc = NodesImport.getPluginByName(vrsceneDict, maName) ntree = bpy.data.node_groups.new(maName, type='VRayNodeTreeMaterial') ntree.use_fake_user = True outputNode = ntree.nodes.new('VRayNodeOutputMaterial') maNode = NodesImport.createNode(ntree, outputNode, vrsceneDict, pluginDesc) ntree.links.new(maNode.outputs['Material'], outputNode.inputs['Material']) NodesTools.rearrangeTree(ntree, outputNode) NodesTools.deselectNodes(ntree) # Finally create a material CreateMaterial(maName, ntree, use_fake_user) return {'FINISHED'}
def ConvertMaterial(scene, ob, ma, textures): VRayMaterial = ma.vray VRayConverter = scene.vray.VRayConverter # This is the last node of the material # NOT the output, but the last Mtl node materialNode = None if VRayMaterial.ntree: outputNode = NodesUtils.GetNodeByType(VRayMaterial.ntree, 'VRayNodeOutputMaterial') materialNode = NodesUtils.GetConnectedNode( VRayMaterial.ntree, outputNode.inputs['Material']) else: if ma.node_tree: if VRayConverter.convert_from == 'CYCLES': return ConvertNodeMaterial(scene, ob, ma) return None debug.PrintInfo("Converting material: %s" % ma.name) nt = _createVRayTree(ma.name, 'Material') outputNode = _createVRayNode(nt, 'OutputMaterial') materialTop = _createVRayNode(nt, 'MtlSingleBRDF') brdfTo = materialTop mainBRDF = None if VRayMaterial.round_edges: mtlRoundEdges = _createVRayNode(nt, 'MtlRoundEdges') mtlRoundEdges.inputs['Radius'].value = VRayMaterial.radius _connectNodes(nt, materialTop, 'Material', mtlRoundEdges, 'Base Mtl') materialTop = mtlRoundEdges if VRayMaterial.material_id_number: mtlMaterialID = _createVRayNode(nt, 'MtlMaterialID') mtlMaterialID.MtlMaterialID.material_id_number = VRayMaterial.material_id_number mtlMaterialID.inputs[ 'Material Id Color'].value = VRayMaterial.material_id_color _connectNodes(nt, materialTop, 'Material', mtlMaterialID, 'Base Mtl') materialTop = mtlMaterialID if VRayMaterial.Mtl2Sided.use: mtl2Sided = _createVRayNode(nt, 'Mtl2Sided') mtl2Sided.Mtl2Sided.force_1sided = VRayMaterial.Mtl2Sided.force_1sided mtl2Sided.inputs['Translucency'].value = [ VRayMaterial.Mtl2Sided.translucency_slider ] * 3 backMat = None if VRayMaterial.Mtl2Sided.back: backMaName = VRayMaterial.Mtl2Sided.back if backMaName in bpy.data.materials: backMa = bpy.data.materials[backMaName] backTex = ProcessTextures(backMa) ConvertMaterial(scene, ob, backMa, backTex) backMat = _createGroupMaterial(nt, backMa) _connectNodes(nt, materialTop, 'Material', mtl2Sided, 'Front') if backMat: _connectNodes(nt, backMat, 'Material', mtl2Sided, 'Back') else: _connectNodes(nt, materialTop, 'Material', mtl2Sided, 'Back') materialTop = mtl2Sided if VRayMaterial.MtlOverride.use: pass for ovrName in {'MtlWrapper', 'MtlRenderStats'}: ovrPropGroup = getattr(VRayMaterial, ovrName) ovrUse = getattr(ovrPropGroup, 'use') if not ovrUse: continue debug.PrintInfo(" Found override: %s" % ovrName) ovrNode = _createVRayNode(nt, ovrName) _connectNodes(nt, materialTop, 'Material', ovrNode, OverrideInputSocket[ovrName]) materialTop = ovrNode # Connect last material to the output materialNode = materialTop _connectNodes(nt, materialTop, 'Material', outputNode, 'Material') # BRDFs # if 'normal' in textures: norTex = _getTextureFromTextures(textures, 'normal') mainBRDF = _createVRayNode(nt, 'BRDFBump') mainBRDF.inputs['Bump Amount Texture'].value = _getBumpAmount(ma) bumpTexNode = norTex.createNode(nt) _connectNodes(nt, bumpTexNode, 'Color', mainBRDF, 'Color Texture') _connectNodes(nt, bumpTexNode, 'Out Intensity', mainBRDF, 'Float Texture') # Finally generate main BRDF node and connect top brdf # if needed brdfType = VRayMaterial.type baseBRDF = _createVRayNode(nt, brdfType) oldPropGroup = getattr(VRayMaterial, brdfType) TransferProperties(baseBRDF, brdfType, oldPropGroup) CreateTextureNodes(nt, baseBRDF, textures) # Manual tweaks if brdfType == 'BRDFVRayMtl': if 'reflect' not in textures: baseBRDF.inputs['Reflect'].value = oldPropGroup.reflect_color if 'refract' not in textures: baseBRDF.inputs['Refract'].value = oldPropGroup.refract_color baseBRDF.inputs['Fog Color Tex'].value = oldPropGroup.fog_color if not mainBRDF: mainBRDF = baseBRDF else: _connectNodes(nt, baseBRDF, 'BRDF', mainBRDF, 'Base Brdf') # Connect last BRDF to the last material _connectNodes(nt, mainBRDF, 'BRDF', brdfTo, 'BRDF') NodesTools.rearrangeTree(nt, outputNode) NodesTools.deselectNodes(nt) VRayMaterial.ntree = nt return materialNode