Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ##### BEGIN LICENSE BLOCK #####
- #
- # Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)
- #
- # This work is licensed under the Creative Commons
- # Attribution-NonCommercial-NoDerivatives 4.0 International License.
- #
- # To view a copy of this license,
- # visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
- #
- # ##### END LICENSE BLOCK #####
- bl_info = {
- "name": "Shader Library",
- "author": "Darkfall",
- "version": (1, 7),
- "blender": (2, 90, 1),
- "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
- from bpy.types import (Panel, Operator, Menu)
- from bpy.props import (FloatProperty, FloatVectorProperty, BoolProperty, IntProperty)
- class ShaderMainPanel(Panel):
- bl_label = " "
- bl_idname = "SHADER_PT_MAINPANEL"
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'UI'
- bl_category = 'Shader Library'
- def draw_header(self, context):
- layout = self.layout
- row = layout.row()
- row.label(text="The Shader Library", icon= 'NODE_MATERIAL')
- def draw(self, context):
- layout = self.layout
- row = layout.row()
- row = layout.row()
- row.label(text= "Select a Shader to be added.")
- row = layout.row()
- #row.label(text= "(Press Shift F - for Shortcut)")
- row.label(text= " (ver 1.07)")
- class SubPanelPreciousMetals(Panel):
- bl_label = "Gemstones"
- 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 Gemstone Shader.")
- row = layout.row()
- row.operator("wm.diamondop", icon= 'DECORATE_ANIMATE', text= "Diamond")
- row = layout.row()
- class SubPanelMaterials(Panel):
- bl_label = "Materials"
- bl_idname = "SHADER_PT_MATERIALS"
- 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 Material Shader.")
- row = layout.row()
- row = layout.row()
- row.operator("wm.leatherop", icon= 'OUTLINER_OB_SURFACE', text= "Leather")
- row = layout.row()
- row.operator("shader.brick_operator", icon= 'MOD_BUILD', text= "Brick")
- class SubPanelMetals(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')
- row = layout.row()
- row.operator('shader.scifigold_operator', icon= 'COLORSET_09_VEC')
- class SubPanelStylized(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("shader.cloud_operator", icon= 'OUTLINER_DATA_VOLUME', text= "Clouds")
- row = layout.row()
- row.operator("wm.ghostop", icon= 'GHOST_ENABLED', text= "Ghost")
- row.operator("wm.hologramop", icon= 'USER', text= "Hologram")
- row = layout.row()
- row.operator("wm.neonop", icon= 'PARTICLE_PATH', text= "Neon")
- row = layout.row()
- row.operator("wm.potionop", icon= 'SORTTIME', text= "Stylized Potion")
- row = layout.row()
- class SHADER_OT_DIAMOND(Operator):
- """Open the Diamond Dialog box"""
- bl_label = " Diamond Operator"
- bl_idname = "wm.diamondop"
- bl_options = {'REGISTER', 'UNDO'}
- col : FloatVectorProperty(name='Color Tint',subtype='COLOR_GAMMA',size=4,default=(1,1,1,1), min= 0, max= 1)
- def execute(self, context):
- c = self.col
- material_diamond = bpy.data.materials.new(name= "Diamond")
- material_diamond.use_nodes = True
- material_diamond.node_tree.nodes.remove(material_diamond.node_tree.nodes.get('Principled BSDF'))
- material_output = material_diamond.node_tree.nodes.get('Material Output')
- material_output.location = (400,0)
- glass1_node = material_diamond.node_tree.nodes.new('ShaderNodeBsdfGlass')
- glass1_node.location = (-600,0)
- glass1_node.inputs[0].default_value = (1, 0, 0, 1)
- glass1_node.inputs[2].default_value = 1.446
- glass2_node = material_diamond.node_tree.nodes.new('ShaderNodeBsdfGlass')
- glass2_node.location = (-600,-150)
- glass2_node.inputs[0].default_value = (0, 1, 0, 1)
- glass2_node.inputs[2].default_value = 1.450
- glass3_node = material_diamond.node_tree.nodes.new('ShaderNodeBsdfGlass')
- glass3_node.location = (-600,-300)
- glass3_node.inputs[0].default_value = (0, 0, 1, 1)
- glass3_node.inputs[2].default_value = 1.545
- add1_node = material_diamond.node_tree.nodes.new('ShaderNodeAddShader')
- add1_node.location = (-400,-50)
- add1_node.label = "Add 1"
- add1_node.hide = True
- add1_node.select = False
- add2_node = material_diamond.node_tree.nodes.new('ShaderNodeAddShader')
- add2_node.location = (-100,0)
- add2_node.label = "Add 2"
- add2_node.hide = True
- add2_node.select = False
- glass4_node = material_diamond.node_tree.nodes.new('ShaderNodeBsdfGlass')
- glass4_node.location = (-150,-150)
- glass4_node.inputs[2].default_value = 1.450
- glass4_node.select = False
- mix1_node = material_diamond.node_tree.nodes.new('ShaderNodeMixShader')
- mix1_node.location = (200,0)
- mix1_node.select = False
- 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])
- bpy.context.object.active_material = material_diamond
- bpy.context.object.active_material.diffuse_color = c
- bpy.context.object.active_material.metallic = 0.3
- if context.scene.render.engine == 'BLENDER_EEVEE':
- context.object.active_material.blend_method = 'HASHED'
- return {'FINISHED'}
- def invoke(self, context, event):
- return context.window_manager.invoke_props_dialog(self, width= 210)
- class SHADER_OT_GOLD(Operator):
- """Add the Basic Gold Shader to your selected Object."""
- bl_label = "Gold"
- bl_idname = 'shader.gold_operator'
- bl_options = {'REGISTER', 'UNDO'}
- roughness : FloatProperty(name='Roughness', default= 0.5, min= 0, max= 1)
- preset_bool : BoolProperty(name= "Set Roughness", default= False)
- def draw(self, context):
- layout= self.layout
- layout.separator(factor= 0.1)
- box = layout.box()
- box.prop(self, "preset_bool")
- if self.preset_bool == True:
- box.label(text= "0 - Glossy 1 - Rough")
- box.prop(self, "roughness", slider= True)
- layout.separator(factor= 1)
- def execute(self, context):
- r = self.roughness
- material_gold = bpy.data.materials.new(name= "Gold")
- material_gold.use_nodes = True
- material_output = material_gold.node_tree.nodes.get('Material Output')
- material_output.location = (600,0)
- material_output.select = False
- rgb_node = material_gold.node_tree.nodes.new('ShaderNodeRGB')
- rgb_node.location = (0,-100)
- rgb_node.outputs[0].default_value = (1, 0.766, 0.336, 1)
- rgb_node.select = False
- rgb_node.hide = True
- principled = material_gold.node_tree.nodes.get('Principled BSDF')
- principled.location = (200,0)
- principled.select = False
- principled.inputs[4].default_value = 1
- principled.inputs[7].default_value = r
- material_gold.node_tree.links.new(rgb_node.outputs[0], principled.inputs[0])
- bpy.context.object.active_material = material_gold
- bpy.context.object.active_material.diffuse_color = (1, 0.766, 0.336, 1)
- bpy.context.object.active_material.metallic = 0.45082
- return {'FINISHED'}
- def invoke(self, context, event):
- return context.window_manager.invoke_props_dialog(self, width= 210)
- class SHADER_OT_SILVER(Operator):
- """Add the Basic Silver Shader to your selected Object."""
- bl_label = "Silver"
- bl_idname = 'shader.silver_operator'
- bl_options = {'REGISTER', 'UNDO'}
- roughness : FloatProperty(name='Roughness', default= 0.5, min= 0, max= 1)
- preset_bool : BoolProperty(name= "Set Roughness", default= False)
- def draw(self, context):
- layout= self.layout
- layout.separator(factor= 0.1)
- box = layout.box()
- box.prop(self, "preset_bool")
- if self.preset_bool == True:
- box.label(text= "0 - Glossy 1 - Rough")
- box.prop(self, "roughness", slider= True)
- layout.separator(factor= 1)
- def execute(self, context):
- r = self.roughness
- material_silver = bpy.data.materials.new(name= "Silver")
- material_silver.use_nodes = True
- material_output = material_silver.node_tree.nodes.get('Material Output')
- material_output.location = (600,0)
- material_output.select = False
- rgb_node = material_silver.node_tree.nodes.new('ShaderNodeRGB')
- rgb_node.location = (0,-100)
- rgb_node.outputs[0].default_value = (0.972, 0.960, 0.915, 1)
- rgb_node.select = False
- rgb_node.hide = True
- principled = material_silver.node_tree.nodes.get('Principled BSDF')
- principled.location = (200,0)
- principled.select = False
- principled.inputs[4].default_value = 1.0
- principled.inputs[7].default_value = r
- material_silver.node_tree.links.new(rgb_node.outputs[0], principled.inputs[0])
- bpy.context.object.active_material = material_silver
- bpy.context.object.active_material.diffuse_color = (0.972, 0.960, 0.915, 1)
- bpy.context.object.active_material.metallic = 0.45082
- return {'FINISHED'}
- def invoke(self, context, event):
- return context.window_manager.invoke_props_dialog(self, width= 210)
- class SHADER_OT_COPPER(Operator):
- """Add the Basic Copper Shader to your selected Object."""
- bl_label = "Copper"
- bl_idname = 'shader.copper_operator'
- bl_options = {'REGISTER', 'UNDO'}
- roughness : FloatProperty(name='Roughness', default= 0.5, min= 0, max= 1)
- preset_bool : BoolProperty(name= "Set Roughness", default= False)
- def draw(self, context):
- layout= self.layout
- layout.separator(factor= 0.1)
- box = layout.box()
- box.prop(self, "preset_bool")
- if self.preset_bool == True:
- box.label(text= "0 - Glossy 1 - Rough")
- box.prop(self, "roughness", slider= True)
- layout.separator(factor= 1)
- def execute(self, context):
- r = self.roughness
- material_copper = bpy.data.materials.new(name= "Copper")
- material_copper.use_nodes = True
- material_output = material_copper.node_tree.nodes.get('Material Output')
- material_output.location = (600,0)
- material_output.select = False
- rgb_node = material_copper.node_tree.nodes.new('ShaderNodeRGB')
- rgb_node.location = (0,-100)
- rgb_node.outputs[0].default_value = (0.955, 0.637, 0.538, 1)
- rgb_node.select = False
- rgb_node.hide = True
- principled = material_copper.node_tree.nodes.get('Principled BSDF')
- principled.location = (200,0)
- principled.select = False
- principled.inputs[4].default_value = 1.0
- principled.inputs[7].default_value = r
- material_copper.node_tree.links.new(rgb_node.outputs[0], principled.inputs[0])
- bpy.context.object.active_material = material_copper
- bpy.context.object.active_material.diffuse_color = (0.955, 0.637, 0.538, 1)
- bpy.context.object.active_material.metallic = 0.45082
- return {'FINISHED'}
- def invoke(self, context, event):
- return context.window_manager.invoke_props_dialog(self, width= 210)
- class WM_OT_ghostOp(Operator):
- """Open the Ghost Dialog box"""
- bl_label = " Ghost Operator"
- bl_idname = "wm.ghostop"
- bl_options = {'REGISTER', 'UNDO'}
- col1 : FloatVectorProperty(name='Outer Color',subtype='COLOR_GAMMA',size=4,default=(0.224322, 0.812741, 1, 1), min= 0, max= 1)
- col2 : FloatVectorProperty(name='Inner Color',subtype='COLOR_GAMMA',size=4,default=(0.137478, 0.345533, 1, 1), min= 0, max= 1)
- trans : FloatProperty(min= 0, max= 1, default= 0.5, description= "Transparancy Value. At 0 the Shader will still have some transparancy but at 1 the Shader will fully Transparent")
- enable_bool : BoolProperty(default= False, description= "This Option will add a subtle effect to the shader. The Whole Object will be Visible through itself.")
- def draw(self, context):
- layout = self.layout
- layout.separator(factor=2)
- layout.prop(self, "col1")
- layout.prop(self, "col2")
- layout.prop(self, "trans", text= "Transparency:", slider= True)
- if context.scene.render.engine == 'CYCLES':
- layout.separator(factor=0.5)
- box = layout.box()
- box.prop(self, "enable_bool", text= "Variant")
- if self.enable_bool == True:
- box.label(text= "This Option will add a subtle effect")
- box.label(text= "to the shader. ")
- box.label(text= "The Whole Object will be Visible.")
- layout.separator(factor=1)
- def execute(self, context):
- c1 = self.col1
- c2 = self.col2
- a = self.trans
- material_ghost = bpy.data.materials.new(name= "Ghost")
- material_ghost.use_nodes = True
- material_output = material_ghost.node_tree.nodes.get('Material Output')
- material_output.location = (1000,0)
- material_output.select = False
- material_ghost.node_tree.nodes.remove(material_ghost.node_tree.nodes.get('Principled BSDF'))
- emiss_node = material_ghost.node_tree.nodes.new('ShaderNodeEmission')
- emiss_node.location = (-200,-90)
- emiss_node.inputs[0].default_value = c1
- emiss_node.inputs[1].default_value = 2
- emiss_node.select = False
- trans_node = material_ghost.node_tree.nodes.new('ShaderNodeBsdfTransparent')
- trans_node.location = (-200,10)
- trans_node.inputs[0].default_value = c2
- trans_node.select = False
- mix_node = material_ghost.node_tree.nodes.new('ShaderNodeMixShader')
- mix_node.location = (400,50)
- mix_node.select = False
- layerw_node = material_ghost.node_tree.nodes.new('ShaderNodeLayerWeight')
- layerw_node.location = (0,150)
- layerw_node.inputs[0].default_value = 0.1
- layerw_node.select = False
- math_node = material_ghost.node_tree.nodes.new('ShaderNodeMath')
- math_node.location = (200,100)
- math_node.inputs[0].default_value = 0.1
- math_node.select = False
- math_node.hide = True
- mix2_node = material_ghost.node_tree.nodes.new('ShaderNodeMixShader')
- mix2_node.location = (800,50)
- mix2_node.select = False
- trans2_node = material_ghost.node_tree.nodes.new('ShaderNodeBsdfTransparent')
- trans2_node.location = (500,-100)
- trans2_node.inputs[0].default_value = (1, 1, 1, 1)
- trans2_node.select = False
- light_node = material_ghost.node_tree.nodes.new('ShaderNodeLightPath')
- light_node.location = (500,500)
- light_node.select = False
- colramp_node = material_ghost.node_tree.nodes.new('ShaderNodeValToRGB')
- colramp_node.location = (700, 200)
- colramp_node.select = False
- colramp_node.color_ramp.elements[0].color = (a, a, a, 1)
- if self.enable_bool == True:
- colramp_node.color_ramp.elements[1].color = (0.85, 0.85, 0.85, 1)
- 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], colramp_node.inputs[0])
- material_ghost.node_tree.links.new(colramp_node.outputs[0], mix2_node.inputs[0])
- material_ghost.node_tree.links.new(mix2_node.outputs[0], material_output.inputs[0])
- bpy.context.object.active_material = material_ghost
- bpy.context.object.active_material.diffuse_color = c1
- if context.scene.render.engine == 'BLENDER_EEVEE':
- context.object.active_material.blend_method = 'HASHED'
- return {'FINISHED'}
- def invoke(self, context, event):
- return context.window_manager.invoke_props_dialog(self, width= 200)
- class WM_OT_hologramOp(Operator):
- """Open the Hologram Dialog box"""
- bl_label = " Hologram Operator"
- bl_idname = "wm.hologramop"
- bl_options = {'REGISTER', 'UNDO'}
- col1 : FloatVectorProperty(name='Color 1',subtype='COLOR_GAMMA',size=4,default=(0.0927682, 1, 0.566671, 1), min= 0, max= 1)
- col2 : FloatVectorProperty(name='Color 2',subtype='COLOR_GAMMA',size=4,default=(0.381055, 1, 0.697353, 1), min= 0, max= 1)
- wire_amount : FloatProperty(default= 0.050, min= 0, soft_max= 1)
- def draw(self, context):
- layout = self.layout
- layout.separator(factor=2)
- layout.prop(self, "col1")
- layout.prop(self, "col2")
- layout.prop(self, "wire_amount", slider= True, text= "Wireframe Size:")
- layout.separator(factor=1)
- def execute(self, context):
- c1 = self.col1
- c2 = self.col2
- material_hologram = bpy.data.materials.new(name= "Hologram")
- material_hologram.use_nodes = True
- material_output = material_hologram.node_tree.nodes.get('Material Output')
- material_output.location = (1000,0)
- material_output.select = False
- material_hologram.node_tree.nodes.remove(material_hologram.node_tree.nodes.get('Principled BSDF'))
- emiss_node = material_hologram.node_tree.nodes.new('ShaderNodeEmission')
- emiss_node.location = (-200,-90)
- emiss_node.inputs[0].default_value = c1
- emiss_node.inputs[1].default_value = 2
- emiss_node.select = False
- trans1_node = material_hologram.node_tree.nodes.new('ShaderNodeBsdfTransparent')
- trans1_node.location = (-200,10)
- trans1_node.inputs[0].default_value = c2
- trans1_node.select = False
- mix1_node = material_hologram.node_tree.nodes.new('ShaderNodeMixShader')
- mix1_node.location = (400,50)
- mix1_node.select = False
- layerw_node = material_hologram.node_tree.nodes.new('ShaderNodeLayerWeight')
- layerw_node.location = (0,150)
- layerw_node.inputs[0].default_value = 0.1
- layerw_node.select = False
- math_node = material_hologram.node_tree.nodes.new('ShaderNodeMath')
- math_node.location = (200,100)
- math_node.inputs[0].default_value = 0.1
- math_node.select = False
- math_node.hide = True
- mix2_node = material_hologram.node_tree.nodes.new('ShaderNodeMixShader')
- mix2_node.location = (600,50)
- mix2_node.select = False
- wire_node = material_hologram.node_tree.nodes.new('ShaderNodeWireframe')
- wire_node.location = (100,200)
- wire_node.select = False
- wire_node.use_pixel_size = True
- wire_node.inputs[0].default_value = self.wire_amount
- reroute = material_hologram.node_tree.nodes.new('NodeReroute')
- reroute.location = (-150,-90)
- 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])
- bpy.context.object.active_material = material_hologram
- bpy.context.object.active_material.diffuse_color = c1
- if context.scene.render.engine == 'BLENDER_EEVEE':
- context.object.active_material.blend_method = 'HASHED'
- return {'FINISHED'}
- def invoke(self, context, event):
- return context.window_manager.invoke_props_dialog(self, width= 180)
- class WM_OT_neonOp(Operator):
- """Open the Neon Dialog box"""
- bl_label = " Neon Operator"
- bl_idname = "wm.neonop"
- bl_options = {'REGISTER', 'UNDO'}
- col : FloatVectorProperty(name='Color',subtype='COLOR_GAMMA',size=4,default=(0.269619, 0.601632, 0.8, 1), min= 0, max= 1)
- def execute(self, context):
- c = self.col
- cur_frame = bpy.context.scene.frame_current
- material_neon = bpy.data.materials.new(name= "Neon")
- material_neon.use_nodes = True
- tree = material_neon.node_tree
- material_neon.node_tree.nodes.remove(material_neon.node_tree.nodes.get('Principled BSDF'))
- material_output = material_neon.node_tree.nodes.get('Material Output')
- material_output.location = (400,0)
- emiss_node = material_neon.node_tree.nodes.new('ShaderNodeEmission')
- emiss_node.location = (200,0)
- emiss_node.inputs[0].default_value = c
- emiss_node.inputs[1].default_value = 1.5
- emiss_node.inputs[1].keyframe_insert("default_value", frame= cur_frame)
- data_path = f'nodes["{emiss_node.name}"].inputs[1].default_value'
- 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])
- bpy.context.object.active_material = material_neon
- bpy.context.object.active_material.diffuse_color = c
- return {'FINISHED'}
- def invoke(self, context, event):
- return context.window_manager.invoke_props_dialog(self, width= 150)
- class WM_OT_potionOp(Operator):
- """Open the Stylized Potion Dialog box"""
- bl_label = " Stylized Potion Operator"
- bl_idname = "wm.potionop"
- bl_options = {'REGISTER', 'UNDO'}
- col1 : FloatVectorProperty(name='',subtype='COLOR_GAMMA',size=4,default=(1, 0, 0.0018755, 1), min= 0, max= 1, description= "Select the First Color")
- col2 : FloatVectorProperty(name='',subtype='COLOR_GAMMA',size=4,default=(0.255103, 0, 0.000564289, 1), min= 0, max= 1, description= "Select the Second Color")
- animate : BoolProperty(name= "Animate Shader", default= False, description= "Enable the Animation for the Shader")
- start : IntProperty(name= "Start Frame", default = 0, description= "Set the Start Frame for your animation")
- end : IntProperty(name= "End Frame", default = 250, description= "Set the End Frame for your Animation")
- def invoke(self, context, event):
- return context.window_manager.invoke_props_dialog(self)
- def draw(self, context):
- layout = self.layout
- layout.separator(factor= 2)
- row= layout.row()
- split = row.split(factor= 0.7)
- split.label(text= " Color 1: ")
- split.prop(self, "col1")
- row= layout.row()
- split = row.split(factor= 0.7)
- split.label(text= " Color 2:" )
- split.prop(self, "col2")
- row= layout.row()
- row.separator(factor= 2)
- box = layout.box()
- row = box.row()
- row.prop(self, "animate")
- if self.animate == False:
- row.label(text= "(Shader is Not Animated)")
- if self.animate == True:
- row.label(text= "(Shader is Animated)")
- row = box.row()
- box.prop(self, "start")
- box.prop(self, "end")
- layout.separator(factor= 1)
- def execute(self, context):
- s = self.start
- e = self.end
- c1 = self.col1
- c2 = self.col2
- a = self.animate
- m1 = " : (animated)"
- if a == True:
- material_potion = bpy.data.materials.new(name= "Stylized Potion" + m1)
- else:
- material_potion = bpy.data.materials.new(name= "Stylized Potion")
- material_potion.use_nodes = True
- tree = material_potion.node_tree
- prin_node = material_potion.node_tree.nodes.get('Principled BSDF')
- prin_node.location = (200,0)
- 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
- material_output = material_potion.node_tree.nodes.get('Material Output')
- material_output.location = (500,0)
- rgb1_node = material_potion.node_tree.nodes.new('ShaderNodeRGB')
- rgb1_node.location = (-200,0)
- rgb1_node.outputs[0].default_value = c1
- rgb2_node = material_potion.node_tree.nodes.new('ShaderNodeRGB')
- rgb2_node.location = (-200,-200)
- rgb2_node.outputs[0].default_value = c2
- mix_node = material_potion.node_tree.nodes.new('ShaderNodeMixRGB')
- 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 = 5
- noise_node.inputs[5].default_value = 0.2
- if a == True:
- noise_node.inputs[5].keyframe_insert("default_value", frame= s-150)
- noise_node.inputs[5].default_value = 1.2
- noise_node.inputs[5].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
- link = material_potion.node_tree.links.new
- 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])
- bpy.context.object.active_material = material_potion
- bpy.context.object.active_material.diffuse_color = c1
- return {'FINISHED'}
- class SHADER_OT_LEATHER(Operator):
- """Open the Leather Shader Dialog box"""
- bl_label = " Leather Operator"
- bl_idname = "wm.leatherop"
- bl_options = {'REGISTER', 'UNDO'}
- col : FloatVectorProperty(name='Color',subtype='COLOR_GAMMA',size=4,default=(0.123239, 0.071147, 0.0570714, 1), min= 0, max= 1)
- def execute(self, context):
- c = self.col
- material_leather = bpy.data.materials.new(name= "Leather")
- material_leather.use_nodes = True
- principled = material_leather.node_tree.nodes.get('Principled BSDF')
- principled.inputs[0].default_value = c
- principled.inputs[5].default_value = 0.161
- principled.inputs[7].default_value = 0.367
- material_output = material_leather.node_tree.nodes.get('Material Output')
- material_output.location = (400,0)
- mus_node = material_leather.node_tree.nodes.new('ShaderNodeTexMusgrave')
- mus_node.location = (-600,0)
- mus_node.musgrave_type = 'MULTIFRACTAL'
- mus_node.inputs[2].default_value = 148
- mus_node.inputs[3].default_value = 12.6
- mus_node.inputs[4].default_value = 92
- mus_node.inputs[5].default_value = 2.3
- disp_node = material_leather.node_tree.nodes.new('ShaderNodeDisplacement')
- disp_node.location = (-400,0)
- disp_node.inputs[2].default_value= 0.190
- material_leather.node_tree.links.new(mus_node.outputs[0], disp_node.inputs[0])
- material_leather.node_tree.links.new(disp_node.outputs[0], material_output.inputs[2])
- bpy.context.object.active_material = material_leather
- bpy.context.object.active_material.diffuse_color = c
- bpy.context.object.active_material.metallic = 0.3
- return {'FINISHED'}
- def invoke(self, context, event):
- return context.window_manager.invoke_props_dialog(self, width= 210)
- class SHADER_OT_CLOUD(Operator):
- """Add the Basic Cloud Shader to your selected Object."""
- bl_label = "Cloud"
- bl_idname = 'shader.cloud_operator'
- bl_options = {'REGISTER', 'UNDO'}
- def execute(self, context):
- material_cloud = bpy.data.materials.new(name= "Clouds")
- material_cloud.use_nodes = True
- material_output = material_cloud.node_tree.nodes.get('Material Output')
- material_output.location = (100,0)
- material_output.select = False
- material_cloud.node_tree.nodes.remove(material_cloud.node_tree.nodes.get('Principled BSDF'))
- volume_node = material_cloud.node_tree.nodes.new('ShaderNodeVolumePrincipled')
- volume_node.location = (-200,0)
- volume_node.select = False
- colramp_node = material_cloud.node_tree.nodes.new('ShaderNodeValToRGB')
- colramp_node.location = (-500,0)
- colramp_node.color_ramp.elements[0].position = 0.503798
- colramp_node.color_ramp.elements[1].position = 0.58481
- noise_node = material_cloud.node_tree.nodes.new('ShaderNodeTexNoise')
- noise_node.location = (-700,0)
- noise_node.inputs[2].default_value = 1
- noise_node.inputs[3].default_value = 20
- mapping_node = material_cloud.node_tree.nodes.new('ShaderNodeMapping')
- mapping_node.location = (-900, 0)
- coord_node = material_cloud.node_tree.nodes.new('ShaderNodeTexCoord')
- coord_node.location = (-1100,0)
- material_cloud.node_tree.links.new(colramp_node.outputs[0], volume_node.inputs[2])
- material_cloud.node_tree.links.new(noise_node.outputs[1], colramp_node.inputs[0])
- material_cloud.node_tree.links.new(mapping_node.outputs[0], noise_node.inputs[0])
- material_cloud.node_tree.links.new(coord_node.outputs[3], mapping_node.inputs[0])
- material_cloud.node_tree.links.new(volume_node.outputs[0], material_output.inputs[1])
- bpy.context.object.active_material = material_cloud
- return {'FINISHED'}
- class SHADER_OT_SCIFIGOLD(Operator):
- """Add the Basic Scifi Gold Shader to your selected Object."""
- bl_label = "Sci-fi Gold"
- bl_idname = 'shader.scifigold_operator'
- bl_options = {'REGISTER', 'UNDO'}
- def execute(self, context):
- material_scifigold = bpy.data.materials.new(name= "Sci-fi Gold")
- material_scifigold.use_nodes = True
- material_output = material_scifigold.node_tree.nodes.get('Material Output')
- material_output.location = (600,0)
- material_output.select = False
- rgb_node = material_scifigold.node_tree.nodes.new('ShaderNodeRGB')
- rgb_node.location = (-200,0)
- rgb_node.outputs[0].default_value = (1, 0.766, 0.336, 1)
- rgb_node.select = False
- rgb_node.hide = True
- principled = material_scifigold.node_tree.nodes.get('Principled BSDF')
- principled.location = (200,0)
- principled.select = False
- principled.inputs[4].default_value = 1.0
- bump_node = material_scifigold.node_tree.nodes.new('ShaderNodeBump')
- bump_node.location = (0, -600)
- bump_node.inputs[0].default_value = 0.270
- brick_node = material_scifigold.node_tree.nodes.new('ShaderNodeTexBrick')
- brick_node.location = (-400, -600)
- noise_node = material_scifigold.node_tree.nodes.new('ShaderNodeTexNoise')
- noise_node.location = (-600, -800)
- colramp_node = material_scifigold.node_tree.nodes.new('ShaderNodeValToRGB')
- colramp_node.location = (-100, -300)
- colramp_node.color_ramp.elements[0].color = (0.293851, 0.293851, 0.293851, 1)
- colramp_node.color_ramp.elements[1].color = (0.373086, 0.373086, 0.373086, 1)
- mix_node = material_scifigold.node_tree.nodes.new('ShaderNodeMixRGB')
- mix_node.location = (0, 0)
- mix_node.blend_type = 'MULTIPLY'
- mix_node.inputs[2].default_value = (0.412679, 0.412679, 0.412679, 1)
- mix_node.use_clamp = True
- link = material_scifigold.node_tree.links.new
- link(mix_node.outputs[0], principled.inputs[0])
- link(rgb_node.outputs[0], mix_node.inputs[1])
- link(colramp_node.outputs[0], principled.inputs[7])
- link(bump_node.outputs[0], principled.inputs[19])
- link(brick_node.outputs[0], bump_node.inputs[2])
- link(brick_node.outputs[1], colramp_node.inputs[0])
- link(brick_node.outputs[1], mix_node.inputs[0])
- link(noise_node.outputs[0], brick_node.inputs[0])
- bpy.context.object.active_material = material_scifigold
- return {'FINISHED'}
- class SHADER_OT_BRICK(Operator):
- """Add the Basic Brick Shader to your selected Object."""
- bl_label = "Brick"
- bl_idname = 'shader.brick_operator'
- bl_options = {'REGISTER', 'UNDO'}
- def execute(self, context):
- material_brick = bpy.data.materials.new(name= "Brick")
- material_brick.use_nodes = True
- material_output = material_brick.node_tree.nodes.get('Material Output')
- material_output.location = (600,0)
- material_output.select = False
- rgb_node = material_brick.node_tree.nodes.new('ShaderNodeRGB')
- rgb_node.location = (-400,0)
- rgb_node.outputs[0].default_value = (1, 0.90445, 0.70086, 1)
- rgb_node.select = False
- rgb_node.hide = True
- principled = material_brick.node_tree.nodes.get('Principled BSDF')
- principled.location = (200,0)
- principled.select = False
- principled.inputs[7].default_value = 0.796203
- bump_node = material_brick.node_tree.nodes.new('ShaderNodeBump')
- bump_node.location = (0, -600)
- bump_node.inputs[0].default_value = 0.5
- brick_node = material_brick.node_tree.nodes.new('ShaderNodeTexBrick')
- brick_node.location = (-400, -600)
- brick_node.inputs[4].default_value = 2.9
- brick_node.inputs[5].default_value = 0.01
- noise_node = material_brick.node_tree.nodes.new('ShaderNodeTexNoise')
- noise_node.location = (-400, -200)
- noise_node.inputs[1].default_value = -9.740
- noise_node.inputs[2].default_value = 4.5
- noise_node.inputs[3].default_value = 0
- mix_node = material_brick.node_tree.nodes.new('ShaderNodeMixRGB')
- mix_node.location = (0, 0)
- mix_node.blend_type = 'MULTIPLY'
- mix_node.inputs[2].default_value = (0.440389, 0.440389, 0.440389, 1)
- mix_node.use_clamp = True
- mix2_node = material_brick.node_tree.nodes.new('ShaderNodeMixRGB')
- mix2_node.location = (-200, 0)
- mix_node.use_clamp = True
- mix_node.inputs[0].default_value = 0.4
- coord_node = material_brick.node_tree.nodes.new('ShaderNodeTexCoord')
- coord_node.location = (-1000,-600)
- mapping_node = material_brick.node_tree.nodes.new('ShaderNodeMapping')
- mapping_node.location = (-800,-600)
- mapping_node.inputs[3].default_value[0] = 2.5
- mapping_node.inputs[3].default_value[1] = 2.5
- mapping_node.inputs[3].default_value[2] = 2.5
- link = material_brick.node_tree.links.new
- link(mix_node.outputs[0], principled.inputs[0])
- link(bump_node.outputs[0], principled.inputs[19])
- link(brick_node.outputs[0], bump_node.inputs[2])
- link(brick_node.outputs[1], mix_node.inputs[0])
- link(mapping_node.outputs[0], brick_node.inputs[0])
- link(coord_node.outputs[2], mapping_node.inputs[0])
- link(mix2_node.outputs[0], mix_node.inputs[1])
- link(rgb_node.outputs[0], mix2_node.inputs[1])
- link(noise_node.outputs[0], mix2_node.inputs[2])
- bpy.context.object.active_material = material_brick
- return {'FINISHED'}
- class NODE_MT_materials(Menu):
- """The Materials section contains: Leather."""
- bl_label = "Materials"
- bl_idname = "node.mat_MT_menu"
- def draw(self, context):
- layout = self.layout
- layout.operator("wm.leatherop", text= "Leather Shader", icon= 'OUTLINER_OB_SURFACE')
- class NODE_MT_metallics(Menu):
- """The Metallics section contains: Gold, Silver and Copper."""
- bl_label = "Metallics"
- bl_idname = "node.met_MT_menu"
- def draw(self, context):
- layout = self.layout
- layout.operator("shader.gold_operator", text= "Gold Shader", icon= 'KEYTYPE_KEYFRAME_VEC')
- layout.operator("shader.silver_operator", text= "Silver Shader", icon= 'HANDLETYPE_FREE_VEC')
- layout.operator("shader.copper_operator", text= "Copper Shader", icon= 'KEYTYPE_EXTREME_VEC')
- class NODE_MT_gems(Menu):
- """The Gemstones section contains: The Diamond Shader."""
- bl_label = "Gemstones"
- bl_idname = "node.gem_MT_menu"
- def draw(self, context):
- layout = self.layout
- layout.operator("wm.diamondop", text= "Diamond Shader", icon= 'DECORATE_ANIMATE')
- class NODE_MT_stylized(Menu):
- """The Stylized section contains: The Ghost Shader, The Hologram Shader, The Neon Shader and the Stylized Potion Shader."""
- bl_label = "Stylized"
- bl_idname = "node.stylized_MT_menu"
- def draw(self, context):
- layout = self.layout
- layout.operator("wm.ghostop", text= "Ghost Shader", icon= 'GHOST_ENABLED')
- layout.operator("wm.hologramop", text= "Hologram Shader", icon= 'USER')
- layout.operator("wm.neonop", text= "Neon Shader", icon= 'MOD_SMOOTH')
- layout.operator("wm.potionop", text= "Potion Shader", icon= 'SORTTIME')
- class WM_OT_Shortcut(Operator):
- """Custom Operator"""
- bl_label = "Add Shader Menu"
- bl_idname = "wm.call_shader_menu"
- bl_options = {'REGISTER', 'UNDO'}
- def draw(self, context):
- layout = self.layout
- box = layout.box()
- box.menu("node.gem_MT_menu")
- box.menu("node.mat_MT_menu")
- box.menu("node.met_MT_menu")
- box.menu("node.stylized_MT_menu")
- def execute(self, context):
- return {'FINISHED'}
- def invoke(self, context, event):
- wm = context.window_manager
- return wm.invoke_props_dialog(self)
- addon_keymaps = []
- classes = [WM_OT_Shortcut, NODE_MT_gems, NODE_MT_materials, NODE_MT_metallics, NODE_MT_stylized, ShaderMainPanel, SubPanelMaterials, SubPanelMetals, SubPanelPreciousMetals, SubPanelStylized, SHADER_OT_LEATHER, SHADER_OT_DIAMOND, SHADER_OT_GOLD, SHADER_OT_SILVER, SHADER_OT_COPPER, SHADER_OT_CLOUD, SHADER_OT_SCIFIGOLD, SHADER_OT_BRICK, WM_OT_ghostOp, WM_OT_hologramOp, WM_OT_neonOp, WM_OT_potionOp]
- def register():
- for cls in classes:
- bpy.utils.register_class(cls)
- wm = bpy.context.window_manager
- kc = wm.keyconfigs.addon
- if kc:
- km = kc.keymaps.new(name='3D View', space_type= 'VIEW_3D')
- kmi = km.keymap_items.new("wm.call_shader_menu", type= 'F', value= 'PRESS', shift= True)
- addon_keymaps.append((km, kmi))
- def unregister():
- for km,kmi in addon_keymaps:
- km.keymap_items.remove(kmi)
- addon_keymaps.clear()
- for cls in classes:
- bpy.utils.unregister_class(cls)
- if __name__ == "__main__":
- register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement