Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bl_info = {
- "name": "Shader Library",
- "author": "Darkfall",
- "version": (1, 2),
- "blender": (2, 80, 0),
- "location": "View3D > Toolshelf",
- "description": "Select from the Various Different Shaders, and they will be addded to your selected object",
- "warning": "",
- "wiki_url": "",
- "category": "Add Shader",
- }
- import bpy
- #create Main Panel
- class ShaderMainPanel(bpy.types.Panel):
- bl_label = "Shader Library"
- bl_idname = "SHADER_PT_MAINPANEL"
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'UI'
- bl_category = 'Shader Library'
- def draw(self, context):
- layout = self.layout
- row = layout.row()
- row.label(text= "Select a Shader to be added.")
- #Create Sub Panel (Metallics)
- class SubPanelMetals(bpy.types.Panel):
- bl_label = "Metallics"
- bl_idname = "SHADER_PT_METALS"
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'UI'
- bl_category = 'Shader Library'
- bl_parent_id = 'SHADER_PT_MAINPANEL'
- bl_options = {'DEFAULT_CLOSED'}
- def draw(self, context):
- layout = self.layout
- layout.scale_y = 1.1
- row = layout.row()
- row.label(text= "Select a Basic Metallic Shader.")
- row = layout.row()
- row = layout.row()
- row.operator('shader.gold_operator', icon= 'KEYTYPE_KEYFRAME_VEC')
- row.operator('shader.silver_operator', icon= 'HANDLETYPE_FREE_VEC')
- row.operator('shader.copper_operator', icon= 'KEYTYPE_EXTREME_VEC')
- #Create Sub Panel (Precious Metals)
- class SubPanelPreciousMetals(bpy.types.Panel):
- bl_label = "Precious Metals"
- bl_idname = "SHADER_PT_PRECIOUSMETALS"
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'UI'
- bl_category = 'Shader Library'
- bl_parent_id = 'SHADER_PT_MAINPANEL'
- bl_options = {'DEFAULT_CLOSED'}
- def draw(self, context):
- layout = self.layout
- layout.scale_y = 1.1
- row = layout.row()
- row.label(text= "Select a Precious Metal Shader.")
- row = layout.row()
- row.operator('shader.diamond_operator', icon= 'DECORATE_ANIMATE')
- row = layout.row()
- #Create Sub Panel (Stylized)
- class SubPanelStylized(bpy.types.Panel):
- bl_label = "Stylized"
- bl_idname = "SHADER_PT_STYLIZED"
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'UI'
- bl_category = 'Shader Library'
- bl_parent_id = 'SHADER_PT_MAINPANEL'
- bl_options = {'DEFAULT_CLOSED'}
- def draw(self, context):
- layout = self.layout
- layout.scale_y = 1.1
- row = layout.row()
- row.label(text= "Select a Stylized Shader.")
- row = layout.row()
- row.operator("wm.ghostop", icon= 'GHOST_ENABLED')
- row.operator("wm.hologramop", icon= 'USER')
- row = layout.row()
- row.operator("wm.neonop", icon= 'PARTICLE_PATH')
- row = layout.row()
- row.operator("wm.potionop", icon= 'SORTTIME')
- row = layout.row()
- #Create a Custom Operator for the Diamond Shader
- class SHADER_OT_DIAMOND(bpy.types.Operator):
- """Add the Diamond Shader to your selected Object."""
- bl_label = "Diamond"
- bl_idname = 'shader.diamond_operator'
- def execute(self, context):
- #Creating a New Shader and calling it Diamond
- material_diamond = bpy.data.materials.new(name= "Diamond")
- #Enabling Use Nodes
- material_diamond.use_nodes = True
- #removing the Principled Node
- material_diamond.node_tree.nodes.remove(material_diamond.node_tree.nodes.get('Principled BSDF'))
- #Create a reference to the Material Output
- material_output = material_diamond.node_tree.nodes.get('Material Output')
- #Set location of node
- material_output.location = (400,0)
- #Adding Glass1 Node
- glass1_node = material_diamond.node_tree.nodes.new('ShaderNodeBsdfGlass')
- #Set location of node
- glass1_node.location = (-600,0)
- #Setting the Default Color
- glass1_node.inputs[0].default_value = (1, 0, 0, 1)
- #Setting the Default IOR Value
- glass1_node.inputs[2].default_value = 1.446
- #Adding Glass2 Node
- glass2_node = material_diamond.node_tree.nodes.new('ShaderNodeBsdfGlass')
- #Set location of node
- glass2_node.location = (-600,-150)
- #Setting the Default Color
- glass2_node.inputs[0].default_value = (0, 1, 0, 1)
- #Setting the Default IOR Value
- glass2_node.inputs[2].default_value = 1.450
- #Adding Glass3 Node
- glass3_node = material_diamond.node_tree.nodes.new('ShaderNodeBsdfGlass')
- #Set location of node
- glass3_node.location = (-600,-300)
- #Setting the Default Color
- glass3_node.inputs[0].default_value = (0, 0, 1, 1)
- #Setting the Default IOR Value
- glass3_node.inputs[2].default_value = 1.545
- #Create the Add Shader Node and Reference it as 'Add1'
- add1_node = material_diamond.node_tree.nodes.new('ShaderNodeAddShader')
- #Setting the Location
- add1_node.location = (-400,-50)
- #Setting the Label
- add1_node.label = "Add 1"
- #Minimizes the Node
- add1_node.hide = True
- #Deselect the Node
- add1_node.select = False
- #Create the Add Shader Node and Reference it as 'Add2'
- add2_node = material_diamond.node_tree.nodes.new('ShaderNodeAddShader')
- #Setting the Location
- add2_node.location = (-100,0)
- #Setting the Label
- add2_node.label = "Add 2"
- #Minimizes the Node
- add2_node.hide = True
- #Deselect the Node
- add2_node.select = False
- #Create the Glass Node and Reference it as 'glass4'
- glass4_node = material_diamond.node_tree.nodes.new('ShaderNodeBsdfGlass')
- #Setting the Location
- glass4_node.location = (-150,-150)
- #Setting the default color
- glass4_node.inputs[0].default_value = (1, 1, 1, 1)
- #Setting the default IOR
- glass4_node.inputs[2].default_value = 1.450
- #Deselect the Node
- glass4_node.select = False
- #Create the Mix Shader Node and Reference it as 'Mix1'
- mix1_node = material_diamond.node_tree.nodes.new('ShaderNodeMixShader')
- #Setting the Location
- mix1_node.location = (200,0)
- #Deselect the Node
- mix1_node.select = False
- #Creating Links between the Nodes
- material_diamond.node_tree.links.new(glass1_node.outputs[0], add1_node.inputs[0])
- material_diamond.node_tree.links.new(glass2_node.outputs[0], add1_node.inputs[1])
- material_diamond.node_tree.links.new(add1_node.outputs[0], add2_node.inputs[0])
- material_diamond.node_tree.links.new(glass3_node.outputs[0], add2_node.inputs[1])
- material_diamond.node_tree.links.new(add2_node.outputs[0], mix1_node.inputs[1])
- material_diamond.node_tree.links.new(glass4_node.outputs[0], mix1_node.inputs[2])
- material_diamond.node_tree.links.new(mix1_node.outputs[0], material_output.inputs[0])
- #Adding Material to the currently selected object
- bpy.context.object.active_material = material_diamond
- return {'FINISHED'}
- #Operator for the Gold (basic) Shader
- class SHADER_OT_GOLD(bpy.types.Operator):
- """Add the Basic Gold Shader to your selected Object."""
- bl_label = "Gold"
- bl_idname = 'shader.gold_operator'
- def execute(self, context):
- #Create a Shader Material and name it Gold
- material_gold = bpy.data.materials.new(name= "Gold")
- #Use Nodes for this Material
- material_gold.use_nodes = True
- #Create reference to the Material Output
- material_output = material_gold.node_tree.nodes.get('Material Output')
- material_output.location = (600,0)
- material_output.select = False
- #Create the RGB Node and Reference it as 'rgb_node'
- rgb_node = material_gold.node_tree.nodes.new('ShaderNodeRGB')
- #Setting the Location
- rgb_node.location = (0,-100)
- #Setting the default color
- rgb_node.outputs[0].default_value = (1, 0.766, 0.336, 1)
- #Deselect the Node
- rgb_node.select = False
- #Minimize the Node
- rgb_node.hide = True
- #Create reference to the Principled Node
- principled = material_gold.node_tree.nodes.get('Principled BSDF')
- principled.location = (200,0)
- principled.select = False
- principled.inputs[4].default_value = 1.0
- #Connecting (known as creating links) between the
- material_gold.node_tree.links.new(rgb_node.outputs[0], principled.inputs[0])
- #Adding Material to the currently selected object
- bpy.context.object.active_material = material_gold
- return {'FINISHED'}
- #Operator for the Silver (basic) Shader
- class SHADER_OT_SILVER(bpy.types.Operator):
- """Add the Basic Silver Shader to your selected Object."""
- bl_label = "Silver"
- bl_idname = 'shader.silver_operator'
- def execute(self, context):
- #Create a Shader Material and name it Silver
- material_silver = bpy.data.materials.new(name= "Silver")
- #Use Nodes for this Material
- material_silver.use_nodes = True
- #Create reference to the Material Output
- material_output = material_silver.node_tree.nodes.get('Material Output')
- material_output.location = (600,0)
- material_output.select = False
- #Create the RGB Node and Reference it as 'rgb_node'
- rgb_node = material_silver.node_tree.nodes.new('ShaderNodeRGB')
- #Setting the Location
- rgb_node.location = (0,-100)
- #Setting the default color
- rgb_node.outputs[0].default_value = (0.972, 0.960, 0.915, 1)
- #Deselect the Node
- rgb_node.select = False
- #Minimize the Node
- rgb_node.hide = True
- #Create reference to the Principled Node
- principled = material_silver.node_tree.nodes.get('Principled BSDF')
- principled.location = (200,0)
- principled.select = False
- principled.inputs[4].default_value = 1.0
- #Connecting (known as creating links) between the
- material_silver.node_tree.links.new(rgb_node.outputs[0], principled.inputs[0])
- #Adding Material to the currently selected object
- bpy.context.object.active_material = material_silver
- return {'FINISHED'}
- #Operator for the Copper (basic) Shader
- class SHADER_OT_COPPER(bpy.types.Operator):
- """Add the Basic Copper Shader to your selected Object."""
- bl_label = "Copper"
- bl_idname = 'shader.copper_operator'
- def execute(self, context):
- #Create a Shader Material and name it Copper
- material_copper = bpy.data.materials.new(name= "Copper")
- #Use Nodes for this Material
- material_copper.use_nodes = True
- #Create reference to the Material Output
- material_output = material_copper.node_tree.nodes.get('Material Output')
- material_output.location = (600,0)
- material_output.select = False
- #Create the RGB Node and Reference it as 'rgb_node'
- rgb_node = material_copper.node_tree.nodes.new('ShaderNodeRGB')
- #Setting the Location
- rgb_node.location = (0,-100)
- #Setting the default color
- rgb_node.outputs[0].default_value = (0.955, 0.637, 0.538, 1)
- #Deselect the Node
- rgb_node.select = False
- #Minimize the Node
- rgb_node.hide = True
- #Create reference to the Principled Node
- principled = material_copper.node_tree.nodes.get('Principled BSDF')
- principled.location = (200,0)
- principled.select = False
- principled.inputs[4].default_value = 1.0
- #Connecting (known as creating links) between the
- material_copper.node_tree.links.new(rgb_node.outputs[0], principled.inputs[0])
- #Adding Material to the currently selected object
- bpy.context.object.active_material = material_copper
- return {'FINISHED'}
- #Operator for the Ghost Shader
- class WM_OT_ghostOp(bpy.types.Operator):
- """Open the Ghost Dialog box"""
- bl_label = "Ghost"
- bl_idname = "wm.ghostop"
- col1 = bpy.props.FloatVectorProperty(name='Outer Color',subtype='COLOR_GAMMA',size=4,default=(0.224322, 0.812741, 1, 1))
- col2 = bpy.props.FloatVectorProperty(name='Inner Color',subtype='COLOR_GAMMA',size=4,default=(0.137478, 0.345533, 1, 1))
- def execute(self, context):
- c1 = self.col1
- c2 = self.col2
- #Create a Shader Material and name it Ghost
- material_ghost = bpy.data.materials.new(name= "Ghost")
- #Use Nodes for this Material
- material_ghost.use_nodes = True
- #Create reference to the Material Output
- material_output = material_ghost.node_tree.nodes.get('Material Output')
- material_output.location = (1000,0)
- material_output.select = False
- #Select and remove the default Principled Node
- material_ghost.node_tree.nodes.remove(material_ghost.node_tree.nodes.get('Principled BSDF'))
- #Create the Emission Node and Reference it as 'emiss_node'
- emiss_node = material_ghost.node_tree.nodes.new('ShaderNodeEmission')
- #Setting the Location
- emiss_node.location = (-200,-90)
- #Setting the default color
- emiss_node.inputs[0].default_value = c1
- emiss_node.inputs[1].default_value = 2
- #Deselect the Node
- emiss_node.select = False
- #Create the Transparent Node and Reference it as 'trans_node'
- trans_node = material_ghost.node_tree.nodes.new('ShaderNodeBsdfTransparent')
- #Setting the Location
- trans_node.location = (-200,10)
- #Setting the default color
- trans_node.inputs[0].default_value = c2
- #Deselect the Node
- trans_node.select = False
- #Create the Mix Node and Reference it as 'mix_node'
- mix_node = material_ghost.node_tree.nodes.new('ShaderNodeMixShader')
- #Setting the Location
- mix_node.location = (400,50)
- #Deselect the Node
- mix_node.select = False
- #Create the Layer Weight Node and Reference it as 'layerw_node'
- layerw_node = material_ghost.node_tree.nodes.new('ShaderNodeLayerWeight')
- #Setting the Location
- layerw_node.location = (0,150)
- #Setting the default color
- layerw_node.inputs[0].default_value = 0.1
- #Deselect the Node
- layerw_node.select = False
- #Create the Math Node and Reference it as 'math_node'
- math_node = material_ghost.node_tree.nodes.new('ShaderNodeMath')
- #Setting the Location
- math_node.location = (200,100)
- #Setting the default color
- math_node.inputs[0].default_value = 0.1
- #Deselect the Node
- math_node.select = False
- math_node.hide = True
- #Create the Mix2 Node and Reference it as 'mix2_node'
- mix2_node = material_ghost.node_tree.nodes.new('ShaderNodeMixShader')
- #Setting the Location
- mix2_node.location = (800,50)
- #Deselect the Node
- mix2_node.select = False
- #Create the Transparent2 Node and Reference it as 'trans2_node'
- trans2_node = material_ghost.node_tree.nodes.new('ShaderNodeBsdfTransparent')
- #Setting the Location
- trans2_node.location = (500,-100)
- #Setting the default color
- trans2_node.inputs[0].default_value = (1, 1, 1, 1)
- #Deselect the Node
- trans2_node.select = False
- #Create the LightPath Node and Reference it as 'light_node'
- light_node = material_ghost.node_tree.nodes.new('ShaderNodeLightPath')
- #Setting the Location
- light_node.location = (500,500)
- #Deselect the Node
- light_node.select = False
- #Connecting (known as creating links) between the
- material_ghost.node_tree.links.new(trans_node.outputs[0], mix_node.inputs[1])
- material_ghost.node_tree.links.new(emiss_node.outputs[0], mix_node.inputs[2])
- material_ghost.node_tree.links.new(layerw_node.outputs[0], math_node.inputs[0])
- material_ghost.node_tree.links.new(layerw_node.outputs[1], math_node.inputs[1])
- material_ghost.node_tree.links.new(math_node.outputs[0], mix_node.inputs[0])
- material_ghost.node_tree.links.new(mix_node.outputs[0], mix2_node.inputs[1])
- material_ghost.node_tree.links.new(trans2_node.outputs[0], mix2_node.inputs[2])
- material_ghost.node_tree.links.new(light_node.outputs[11], mix2_node.inputs[0])
- material_ghost.node_tree.links.new(mix2_node.outputs[0], material_output.inputs[0])
- #Adding Material to the currently selected object
- bpy.context.object.active_material = material_ghost
- return {'FINISHED'}
- def invoke(self, context, event):
- return context.window_manager.invoke_props_dialog(self)
- class WM_OT_hologramOp(bpy.types.Operator):
- """Open the Hologram Dialog box"""
- bl_label = "Hologram"
- bl_idname = "wm.hologramop"
- col1 = bpy.props.FloatVectorProperty(name='Color 1',subtype='COLOR_GAMMA',size=4,default=(0.0927682, 1, 0.566671, 1))
- col2 = bpy.props.FloatVectorProperty(name='Color 2',subtype='COLOR_GAMMA',size=4,default=(0.381055, 1, 0.697353, 1))
- def execute(self, context):
- c1 = self.col1
- c2 = self.col2
- #Create a Shader Material and name it Ghost
- material_hologram = bpy.data.materials.new(name= "Hologram")
- #Use Nodes for this Material
- material_hologram.use_nodes = True
- #Create reference to the Material Output
- material_output = material_hologram.node_tree.nodes.get('Material Output')
- material_output.location = (1000,0)
- material_output.select = False
- #Select and remove the default Principled Node
- material_hologram.node_tree.nodes.remove(material_hologram.node_tree.nodes.get('Principled BSDF'))
- #Create the Emission Node and Reference it as 'emiss_node'
- emiss_node = material_hologram.node_tree.nodes.new('ShaderNodeEmission')
- #Setting the Location
- emiss_node.location = (-200,-90)
- #Setting the default color
- emiss_node.inputs[0].default_value = c1
- #Setting the Strength Value
- emiss_node.inputs[1].default_value = 2
- #Deselect the Node
- emiss_node.select = False
- #Create the Transparent Node and Reference it as 'trans1_node'
- trans1_node = material_hologram.node_tree.nodes.new('ShaderNodeBsdfTransparent')
- #Setting the Location
- trans1_node.location = (-200,10)
- #Setting the default color
- trans1_node.inputs[0].default_value = c2
- #Deselect the Node
- trans1_node.select = False
- #Create the Mix1 Node and Reference it as 'mix1_node'
- mix1_node = material_hologram.node_tree.nodes.new('ShaderNodeMixShader')
- #Setting the Location
- mix1_node.location = (400,50)
- #Deselect the Node
- mix1_node.select = False
- #Create the Layer Weight Node and Reference it as 'layerw_node'
- layerw_node = material_hologram.node_tree.nodes.new('ShaderNodeLayerWeight')
- #Setting the Location
- layerw_node.location = (0,150)
- #Setting the default color
- layerw_node.inputs[0].default_value = 0.1
- #Deselect the Node
- layerw_node.select = False
- #Create the Math Node and Reference it as 'math_node'
- math_node = material_hologram.node_tree.nodes.new('ShaderNodeMath')
- #Setting the Location
- math_node.location = (200,100)
- #Setting the default color
- math_node.inputs[0].default_value = 0.1
- #Deselect the Node
- math_node.select = False
- math_node.hide = True
- #Create the Mix2 Node and Reference it as 'mix2_node'
- mix2_node = material_hologram.node_tree.nodes.new('ShaderNodeMixShader')
- #Setting the Location
- mix2_node.location = (600,50)
- #Deselect the Node
- mix2_node.select = False
- #Create the Wireframe Node and Reference it as 'mix_node'
- wire_node = material_hologram.node_tree.nodes.new('ShaderNodeWireframe')
- #Setting the Location
- wire_node.location = (100,200)
- #Deselect the Node
- wire_node.select = False
- #Enable Use Pixel Size
- wire_node.use_pixel_size = True
- #Enable Use Pixel Size
- wire_node.inputs[0].default_value = 0.05
- #create a reroute node
- reroute = material_hologram.node_tree.nodes.new('NodeReroute')
- reroute.location = (-150,-90)
- #Connecting (known as creating links) between the
- material_hologram.node_tree.links.new(trans1_node.outputs[0], mix1_node.inputs[1])
- material_hologram.node_tree.links.new(emiss_node.outputs[0], reroute.inputs[0])
- material_hologram.node_tree.links.new(reroute.outputs[0], mix1_node.inputs[2])
- material_hologram.node_tree.links.new(reroute.outputs[0], mix2_node.inputs[2])
- material_hologram.node_tree.links.new(layerw_node.outputs[0], math_node.inputs[0])
- material_hologram.node_tree.links.new(layerw_node.outputs[1], math_node.inputs[1])
- material_hologram.node_tree.links.new(math_node.outputs[0], mix1_node.inputs[0])
- material_hologram.node_tree.links.new(mix1_node.outputs[0], mix2_node.inputs[1])
- material_hologram.node_tree.links.new(wire_node.outputs[0], mix2_node.inputs[0])
- material_hologram.node_tree.links.new(mix2_node.outputs[0], material_output.inputs[0])
- #Adding Material to the currently selected object
- bpy.context.object.active_material = material_hologram
- return {'FINISHED'}
- def invoke(self, context, event):
- return context.window_manager.invoke_props_dialog(self)
- #Create a Custom Operator for the Neon Shader
- class WM_OT_neonOp(bpy.types.Operator):
- """Open the Neon Dialog box"""
- bl_label = "Neon"
- bl_idname = "wm.neonop"
- col = bpy.props.FloatVectorProperty(name='Color',subtype='COLOR_GAMMA',size=4,default=(0.269619, 0.601632, 0.8, 1))
- def execute(self, context):
- c = self.col
- #Creating reference for the "Current Frame"
- cur_frame = bpy.context.scene.frame_current
- #Creating a New Shader and calling it Neon
- material_neon = bpy.data.materials.new(name= "Neon")
- #Enabling Use Nodes
- material_neon.use_nodes = True
- #Referencing the Node Tree
- tree = material_neon.node_tree
- #removing the Principled Node
- material_neon.node_tree.nodes.remove(material_neon.node_tree.nodes.get('Principled BSDF'))
- #Create a reference to the Material Output
- material_output = material_neon.node_tree.nodes.get('Material Output')
- #Set location of node
- material_output.location = (400,0)
- #Adding Glass1 Node
- emiss_node = material_neon.node_tree.nodes.new('ShaderNodeEmission')
- #Set location of node
- emiss_node.location = (200,0)
- #Setting the Default Color
- emiss_node.inputs[0].default_value = c
- #Setting the Default Strength Value
- emiss_node.inputs[1].default_value = 1.5
- emiss_node.inputs[1].keyframe_insert("default_value", frame= cur_frame)
- #Referencing the Data Path
- data_path = f'nodes["{emiss_node.name}"].inputs[1].default_value'
- #Creating a reference for the Fcurves
- fcurves = tree.animation_data.action.fcurves
- fc = fcurves.find(data_path)
- if fc:
- new_mod = fc.modifiers.new('NOISE')
- new_mod.strength = 10
- new_mod.depth = 1
- material_neon.node_tree.links.new(emiss_node.outputs[0], material_output.inputs[0])
- #Adding Material to the currently selected object
- bpy.context.object.active_material = material_neon
- return {'FINISHED'}
- def invoke(self, context, event):
- return context.window_manager.invoke_props_dialog(self)
- class WM_OT_potionOp(bpy.types.Operator):
- """Open the Stylized Potion Dialog box"""
- bl_label = "Stylized Potion"
- bl_idname = "wm.potionop"
- col1 = bpy.props.FloatVectorProperty(name='Color 1',subtype='COLOR_GAMMA',size=4,default=(1, 0, 0.0018755, 1))
- col2 = bpy.props.FloatVectorProperty(name='Color 2',subtype='COLOR_GAMMA',size=4,default=(0.255103, 0, 0.000564289, 1))
- start = bpy.props.IntProperty(name= "Start Frame", default = 0)
- end = bpy.props.IntProperty(name= "End Frame", default = 250)
- def execute(self, context):
- s = self.start
- e = self.end
- c1 = self.col1
- c2 = self.col2
- #Creating a New Shader and calling it Diamond
- material_potion = bpy.data.materials.new(name= "Stylized Potion")
- #Enabling Use Nodes
- material_potion.use_nodes = True
- tree = material_potion.node_tree
- #Create a reference to the Principled Shader
- prin_node = material_potion.node_tree.nodes.get('Principled BSDF')
- #set location of node
- prin_node.location = (200,0)
- #setting default values
- prin_node.inputs[0].default_value = (0.8, 0.000897912, 0, 1)
- prin_node.inputs[3].default_value = (0.8, 0.1332, 0.0936454, 1)
- prin_node.inputs[7].default_value = 0.076
- prin_node.inputs[15].default_value = 0.947
- #Create a reference to the Material Output
- material_output = material_potion.node_tree.nodes.get('Material Output')
- #Set location of node
- material_output.location = (500,0)
- #adding rgb1 Node
- rgb1_node = material_potion.node_tree.nodes.new('ShaderNodeRGB')
- #set location of the node
- rgb1_node.location = (-200,0)
- #set default color
- rgb1_node.outputs[0].default_value = c1
- #adding rgb2 Node
- rgb2_node = material_potion.node_tree.nodes.new('ShaderNodeRGB')
- #set location of the node
- rgb2_node.location = (-200,-200)
- #set default color
- rgb2_node.outputs[0].default_value = c2
- #adding Mix node
- mix_node = material_potion.node_tree.nodes.new('ShaderNodeMixRGB')
- #set location of the node
- mix_node.location = (0,0)
- noise_node = material_potion.node_tree.nodes.new('ShaderNodeTexNoise')
- noise_node.location = (-500, 200)
- noise_node.inputs[2].default_value = 5
- noise_node.inputs[3].default_value = 0.2
- noise_node.inputs[3].keyframe_insert("default_value", frame= s-150)
- noise_node.inputs[3].default_value = 1.2
- noise_node.inputs[3].keyframe_insert("default_value", frame= e+50)
- ramp_node = material_potion.node_tree.nodes.new('ShaderNodeValToRGB')
- ramp_node.location = (-300, 200)
- ramp_node.color_ramp.elements[0].position = 0.454
- ramp_node.color_ramp.elements[1].position = 0.522
- #creating a reference for the links
- link = material_potion.node_tree.links.new
- #Link the Nodes
- link(rgb1_node.outputs[0], mix_node.inputs[1])
- link(rgb2_node.outputs[0], mix_node.inputs[2])
- link(noise_node.outputs[0], ramp_node.inputs[0])
- link(ramp_node.outputs[0], mix_node.inputs[0])
- link(mix_node.outputs[0], prin_node.inputs[0])
- link(prin_node.outputs[0], material_output.inputs[0])
- #Adding Material to the currently selected object
- bpy.context.object.active_material = material_potion
- return {'FINISHED'}
- def invoke(self, context, event):
- return context.window_manager.invoke_props_dialog(self)
- #registering classes
- def register():
- bpy.utils.register_class(ShaderMainPanel)
- bpy.utils.register_class(SubPanelMetals)
- bpy.utils.register_class(SubPanelPreciousMetals)
- bpy.utils.register_class(SubPanelStylized)
- bpy.utils.register_class(SHADER_OT_DIAMOND)
- bpy.utils.register_class(SHADER_OT_GOLD)
- bpy.utils.register_class(SHADER_OT_SILVER)
- bpy.utils.register_class(SHADER_OT_COPPER)
- bpy.utils.register_class(WM_OT_ghostOp)
- bpy.utils.register_class(WM_OT_hologramOp)
- bpy.utils.register_class(WM_OT_neonOp)
- bpy.utils.register_class(WM_OT_potionOp)
- #unregistering classes
- def unregister():
- bpy.utils.unregister_class(ShaderMainPanel)
- bpy.utils.unregister_class(SubPanelMetals)
- bpy.utils.unregister_class(SubPanelPreciousMetals)
- bpy.utils.unregister_class(SubPanelStylized)
- bpy.utils.unregister_class(SHADER_OT_DIAMOND)
- bpy.utils.unregister_class(SHADER_OT_GOLD)
- bpy.utils.unregister_class(SHADER_OT_SILVER)
- bpy.utils.unregister_class(SHADER_OT_COPPER)
- bpy.utils.unregister_class(WM_OT_ghostOp)
- bpy.utils.unregister_class(WM_OT_hologramOp)
- bpy.utils.unregister_class(WM_OT_neonOp)
- bpy.utils.unregister_class(WM_OT_potionOp)
- #Needed in order to run the script in the editor
- if __name__ == "__main__":
- register()
Add Comment
Please, Sign In to add comment