Guest User

ShaderLibrary

a guest
Mar 1st, 2020
905
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 31.58 KB | None | 0 0
  1. bl_info = {
  2.     "name": "Shader Library",
  3.     "author": "Darkfall",
  4.     "version": (1, 2),
  5.     "blender": (2, 80, 0),
  6.     "location": "View3D > Toolshelf",
  7.     "description": "Select from the Various Different Shaders, and they will be addded to your selected object",
  8.     "warning": "",
  9.     "wiki_url": "",
  10.     "category": "Add Shader",
  11. }
  12.  
  13.  
  14. import bpy
  15.  
  16.     #create Main Panel
  17. class ShaderMainPanel(bpy.types.Panel):
  18.     bl_label = "Shader Library"
  19.     bl_idname = "SHADER_PT_MAINPANEL"
  20.     bl_space_type = 'VIEW_3D'
  21.     bl_region_type = 'UI'
  22.     bl_category = 'Shader Library'
  23.  
  24.     def draw(self, context):
  25.         layout = self.layout
  26.        
  27.         row = layout.row()
  28.         row.label(text= "Select a Shader to be added.")
  29.        
  30.        
  31.  
  32.  
  33.     #Create Sub Panel (Metallics)
  34. class SubPanelMetals(bpy.types.Panel):
  35.     bl_label = "Metallics"
  36.     bl_idname = "SHADER_PT_METALS"
  37.     bl_space_type = 'VIEW_3D'
  38.     bl_region_type = 'UI'
  39.     bl_category = 'Shader Library'
  40.     bl_parent_id = 'SHADER_PT_MAINPANEL'
  41.     bl_options = {'DEFAULT_CLOSED'}
  42.  
  43.     def draw(self, context):
  44.         layout = self.layout
  45.         layout.scale_y = 1.1
  46.        
  47.         row = layout.row()
  48.         row.label(text= "Select a Basic Metallic Shader.")
  49.         row = layout.row()
  50.         row = layout.row()
  51.         row.operator('shader.gold_operator', icon= 'KEYTYPE_KEYFRAME_VEC')
  52.         row.operator('shader.silver_operator', icon= 'HANDLETYPE_FREE_VEC')
  53.         row.operator('shader.copper_operator', icon= 'KEYTYPE_EXTREME_VEC')
  54.  
  55.  
  56.  
  57.  
  58.     #Create Sub Panel (Precious Metals)
  59. class SubPanelPreciousMetals(bpy.types.Panel):
  60.     bl_label = "Precious Metals"
  61.     bl_idname = "SHADER_PT_PRECIOUSMETALS"
  62.     bl_space_type = 'VIEW_3D'
  63.     bl_region_type = 'UI'
  64.     bl_category = 'Shader Library'
  65.     bl_parent_id = 'SHADER_PT_MAINPANEL'
  66.     bl_options = {'DEFAULT_CLOSED'}
  67.  
  68.     def draw(self, context):
  69.         layout = self.layout
  70.         layout.scale_y = 1.1
  71.        
  72.         row = layout.row()
  73.         row.label(text= "Select a Precious Metal Shader.")
  74.         row = layout.row()
  75.         row.operator('shader.diamond_operator', icon= 'DECORATE_ANIMATE')
  76.         row = layout.row()
  77.  
  78.  
  79.  
  80.  
  81.     #Create Sub Panel (Stylized)
  82. class SubPanelStylized(bpy.types.Panel):
  83.     bl_label = "Stylized"
  84.     bl_idname = "SHADER_PT_STYLIZED"
  85.     bl_space_type = 'VIEW_3D'
  86.     bl_region_type = 'UI'
  87.     bl_category = 'Shader Library'
  88.     bl_parent_id = 'SHADER_PT_MAINPANEL'
  89.     bl_options = {'DEFAULT_CLOSED'}
  90.  
  91.     def draw(self, context):
  92.         layout = self.layout
  93.         layout.scale_y = 1.1
  94.        
  95.         row = layout.row()
  96.         row.label(text= "Select a Stylized Shader.")
  97.         row = layout.row()
  98.         row.operator("wm.ghostop", icon= 'GHOST_ENABLED')
  99.         row.operator("wm.hologramop", icon= 'USER')
  100.         row = layout.row()
  101.         row.operator("wm.neonop", icon= 'PARTICLE_PATH')
  102.         row = layout.row()
  103.         row.operator("wm.potionop", icon= 'SORTTIME')
  104.         row = layout.row()
  105.        
  106.  
  107.  
  108.  
  109.  
  110.     #Create a Custom Operator for the Diamond Shader
  111. class SHADER_OT_DIAMOND(bpy.types.Operator):
  112.     """Add the Diamond Shader to your selected Object."""
  113.     bl_label = "Diamond"
  114.     bl_idname = 'shader.diamond_operator'
  115.    
  116.    
  117.     def execute(self, context):
  118.        
  119.             #Creating a New Shader and calling it Diamond
  120.         material_diamond = bpy.data.materials.new(name= "Diamond")
  121.             #Enabling Use Nodes
  122.         material_diamond.use_nodes = True
  123.             #removing the Principled Node
  124.         material_diamond.node_tree.nodes.remove(material_diamond.node_tree.nodes.get('Principled BSDF'))
  125.             #Create a reference to the Material Output
  126.         material_output = material_diamond.node_tree.nodes.get('Material Output')
  127.             #Set location of node
  128.         material_output.location = (400,0)
  129.        
  130.             #Adding Glass1 Node
  131.         glass1_node = material_diamond.node_tree.nodes.new('ShaderNodeBsdfGlass')
  132.             #Set location of node
  133.         glass1_node.location = (-600,0)
  134.             #Setting the Default Color
  135.         glass1_node.inputs[0].default_value = (1, 0, 0, 1)
  136.             #Setting the Default IOR Value
  137.         glass1_node.inputs[2].default_value = 1.446
  138.        
  139.        
  140.             #Adding Glass2 Node
  141.         glass2_node = material_diamond.node_tree.nodes.new('ShaderNodeBsdfGlass')
  142.             #Set location of node
  143.         glass2_node.location = (-600,-150)
  144.             #Setting the Default Color
  145.         glass2_node.inputs[0].default_value = (0, 1, 0, 1)
  146.             #Setting the Default IOR Value
  147.         glass2_node.inputs[2].default_value = 1.450
  148.        
  149.        
  150.             #Adding Glass3 Node
  151.         glass3_node = material_diamond.node_tree.nodes.new('ShaderNodeBsdfGlass')
  152.             #Set location of node
  153.         glass3_node.location = (-600,-300)
  154.             #Setting the Default Color
  155.         glass3_node.inputs[0].default_value = (0, 0, 1, 1)
  156.             #Setting the Default IOR Value
  157.         glass3_node.inputs[2].default_value = 1.545
  158.        
  159.        
  160.        
  161.             #Create the Add Shader Node and Reference it as 'Add1'        
  162.         add1_node = material_diamond.node_tree.nodes.new('ShaderNodeAddShader')
  163.             #Setting the Location
  164.         add1_node.location = (-400,-50)
  165.             #Setting the Label
  166.         add1_node.label = "Add 1"
  167.             #Minimizes the Node
  168.         add1_node.hide = True
  169.             #Deselect the Node
  170.         add1_node.select = False
  171.        
  172.             #Create the Add Shader Node and Reference it as 'Add2'        
  173.         add2_node = material_diamond.node_tree.nodes.new('ShaderNodeAddShader')
  174.             #Setting the Location
  175.         add2_node.location = (-100,0)
  176.             #Setting the Label
  177.         add2_node.label = "Add 2"
  178.             #Minimizes the Node
  179.         add2_node.hide = True
  180.         #Deselect the Node
  181.         add2_node.select = False
  182.        
  183.             #Create the Glass Node and Reference it as 'glass4'        
  184.         glass4_node = material_diamond.node_tree.nodes.new('ShaderNodeBsdfGlass')
  185.             #Setting the Location
  186.         glass4_node.location = (-150,-150)
  187.             #Setting the default color
  188.         glass4_node.inputs[0].default_value = (1, 1, 1, 1)
  189.             #Setting the default IOR
  190.         glass4_node.inputs[2].default_value = 1.450
  191.             #Deselect the Node
  192.         glass4_node.select = False
  193.        
  194.             #Create the Mix Shader Node and Reference it as 'Mix1'        
  195.         mix1_node = material_diamond.node_tree.nodes.new('ShaderNodeMixShader')
  196.             #Setting the Location
  197.         mix1_node.location = (200,0)
  198.             #Deselect the Node
  199.         mix1_node.select = False
  200.        
  201.             #Creating Links between the Nodes
  202.         material_diamond.node_tree.links.new(glass1_node.outputs[0], add1_node.inputs[0])
  203.         material_diamond.node_tree.links.new(glass2_node.outputs[0], add1_node.inputs[1])
  204.         material_diamond.node_tree.links.new(add1_node.outputs[0], add2_node.inputs[0])
  205.         material_diamond.node_tree.links.new(glass3_node.outputs[0], add2_node.inputs[1])
  206.         material_diamond.node_tree.links.new(add2_node.outputs[0], mix1_node.inputs[1])
  207.         material_diamond.node_tree.links.new(glass4_node.outputs[0], mix1_node.inputs[2])
  208.         material_diamond.node_tree.links.new(mix1_node.outputs[0], material_output.inputs[0])
  209.            
  210.             #Adding Material to the currently selected object
  211.         bpy.context.object.active_material = material_diamond
  212.        
  213.         return {'FINISHED'}
  214.        
  215.        
  216.        
  217.        
  218.     #Operator for the Gold (basic) Shader
  219. class SHADER_OT_GOLD(bpy.types.Operator):
  220.     """Add the Basic Gold Shader to your selected Object."""
  221.     bl_label = "Gold"
  222.     bl_idname = 'shader.gold_operator'
  223.    
  224.     def execute(self, context):
  225.        
  226.             #Create a Shader Material and name it Gold
  227.         material_gold = bpy.data.materials.new(name= "Gold")
  228.             #Use Nodes for this Material
  229.         material_gold.use_nodes = True
  230.        
  231.             #Create reference to the Material Output
  232.         material_output = material_gold.node_tree.nodes.get('Material Output')
  233.         material_output.location = (600,0)
  234.         material_output.select = False
  235.        
  236.        
  237.             #Create the RGB Node and Reference it as 'rgb_node'        
  238.         rgb_node = material_gold.node_tree.nodes.new('ShaderNodeRGB')
  239.             #Setting the Location
  240.         rgb_node.location = (0,-100)
  241.             #Setting the default color
  242.         rgb_node.outputs[0].default_value = (1, 0.766, 0.336, 1)
  243.             #Deselect the Node
  244.         rgb_node.select = False
  245.             #Minimize the Node
  246.         rgb_node.hide = True
  247.        
  248.        
  249.             #Create reference to the Principled Node
  250.         principled = material_gold.node_tree.nodes.get('Principled BSDF')
  251.         principled.location = (200,0)
  252.         principled.select = False
  253.         principled.inputs[4].default_value = 1.0
  254.        
  255.        
  256.             #Connecting (known as creating links) between the
  257.         material_gold.node_tree.links.new(rgb_node.outputs[0], principled.inputs[0])
  258.            
  259.            
  260.             #Adding Material to the currently selected object
  261.         bpy.context.object.active_material = material_gold
  262.            
  263.         return {'FINISHED'}
  264.  
  265.  
  266.  
  267.  
  268.     #Operator for the Silver (basic) Shader
  269. class SHADER_OT_SILVER(bpy.types.Operator):
  270.     """Add the Basic Silver Shader to your selected Object."""
  271.     bl_label = "Silver"
  272.     bl_idname = 'shader.silver_operator'
  273.    
  274.     def execute(self, context):
  275.        
  276.             #Create a Shader Material and name it Silver
  277.         material_silver = bpy.data.materials.new(name= "Silver")
  278.             #Use Nodes for this Material
  279.         material_silver.use_nodes = True
  280.        
  281.             #Create reference to the Material Output
  282.         material_output = material_silver.node_tree.nodes.get('Material Output')
  283.         material_output.location = (600,0)
  284.         material_output.select = False
  285.        
  286.      
  287.             #Create the RGB Node and Reference it as 'rgb_node'        
  288.         rgb_node = material_silver.node_tree.nodes.new('ShaderNodeRGB')
  289.             #Setting the Location
  290.         rgb_node.location = (0,-100)
  291.             #Setting the default color
  292.         rgb_node.outputs[0].default_value = (0.972, 0.960, 0.915, 1)
  293.             #Deselect the Node
  294.         rgb_node.select = False
  295.             #Minimize the Node
  296.         rgb_node.hide = True
  297.        
  298.        
  299.             #Create reference to the Principled Node
  300.         principled = material_silver.node_tree.nodes.get('Principled BSDF')
  301.         principled.location = (200,0)
  302.         principled.select = False
  303.         principled.inputs[4].default_value = 1.0
  304.        
  305.      
  306.             #Connecting (known as creating links) between the
  307.         material_silver.node_tree.links.new(rgb_node.outputs[0], principled.inputs[0])
  308.            
  309.            
  310.             #Adding Material to the currently selected object
  311.         bpy.context.object.active_material = material_silver
  312.            
  313.         return {'FINISHED'}
  314.  
  315.  
  316.  
  317.  
  318.     #Operator for the Copper (basic) Shader
  319. class SHADER_OT_COPPER(bpy.types.Operator):
  320.     """Add the Basic Copper Shader to your selected Object."""
  321.     bl_label = "Copper"
  322.     bl_idname = 'shader.copper_operator'
  323.    
  324.     def execute(self, context):
  325.        
  326.             #Create a Shader Material and name it Copper
  327.         material_copper = bpy.data.materials.new(name= "Copper")
  328.             #Use Nodes for this Material
  329.         material_copper.use_nodes = True
  330.        
  331.             #Create reference to the Material Output
  332.         material_output = material_copper.node_tree.nodes.get('Material Output')
  333.         material_output.location = (600,0)
  334.         material_output.select = False
  335.        
  336.        
  337.             #Create the RGB Node and Reference it as 'rgb_node'        
  338.         rgb_node = material_copper.node_tree.nodes.new('ShaderNodeRGB')
  339.             #Setting the Location
  340.         rgb_node.location = (0,-100)
  341.             #Setting the default color
  342.         rgb_node.outputs[0].default_value = (0.955, 0.637, 0.538, 1)
  343.             #Deselect the Node
  344.         rgb_node.select = False
  345.             #Minimize the Node
  346.         rgb_node.hide = True
  347.        
  348.        
  349.             #Create reference to the Principled Node
  350.         principled = material_copper.node_tree.nodes.get('Principled BSDF')
  351.         principled.location = (200,0)
  352.         principled.select = False
  353.         principled.inputs[4].default_value = 1.0
  354.        
  355.        
  356.             #Connecting (known as creating links) between the
  357.         material_copper.node_tree.links.new(rgb_node.outputs[0], principled.inputs[0])
  358.            
  359.            
  360.            #Adding Material to the currently selected object
  361.         bpy.context.object.active_material = material_copper
  362.            
  363.         return {'FINISHED'}
  364.    
  365.    
  366.  
  367.  
  368.  
  369.  
  370.  
  371.     #Operator for the Ghost Shader
  372. class WM_OT_ghostOp(bpy.types.Operator):
  373.     """Open the Ghost Dialog box"""
  374.     bl_label = "Ghost"
  375.     bl_idname = "wm.ghostop"
  376.    
  377.     col1 = bpy.props.FloatVectorProperty(name='Outer Color',subtype='COLOR_GAMMA',size=4,default=(0.224322, 0.812741, 1, 1))
  378.    
  379.     col2 = bpy.props.FloatVectorProperty(name='Inner Color',subtype='COLOR_GAMMA',size=4,default=(0.137478, 0.345533, 1, 1))
  380.    
  381.     def execute(self, context):
  382.        
  383.         c1 = self.col1
  384.         c2 = self.col2
  385.        
  386.             #Create a Shader Material and name it Ghost
  387.         material_ghost = bpy.data.materials.new(name= "Ghost")
  388.             #Use Nodes for this Material
  389.         material_ghost.use_nodes = True
  390.        
  391.             #Create reference to the Material Output
  392.         material_output = material_ghost.node_tree.nodes.get('Material Output')
  393.         material_output.location = (1000,0)
  394.         material_output.select = False
  395.        
  396.         #Select and remove the default Principled Node
  397.         material_ghost.node_tree.nodes.remove(material_ghost.node_tree.nodes.get('Principled BSDF'))
  398.        
  399.        
  400.             #Create the Emission Node and Reference it as 'emiss_node'        
  401.         emiss_node = material_ghost.node_tree.nodes.new('ShaderNodeEmission')
  402.             #Setting the Location
  403.         emiss_node.location = (-200,-90)
  404.             #Setting the default color
  405.         emiss_node.inputs[0].default_value = c1
  406.         emiss_node.inputs[1].default_value = 2
  407.  
  408.             #Deselect the Node
  409.         emiss_node.select = False
  410.            
  411.  
  412.             #Create the Transparent Node and Reference it as 'trans_node'        
  413.         trans_node = material_ghost.node_tree.nodes.new('ShaderNodeBsdfTransparent')
  414.             #Setting the Location
  415.         trans_node.location = (-200,10)
  416.             #Setting the default color
  417.         trans_node.inputs[0].default_value = c2
  418.             #Deselect the Node
  419.         trans_node.select = False
  420.        
  421.        
  422.             #Create the Mix Node and Reference it as 'mix_node'        
  423.         mix_node = material_ghost.node_tree.nodes.new('ShaderNodeMixShader')
  424.             #Setting the Location
  425.         mix_node.location = (400,50)
  426.             #Deselect the Node
  427.         mix_node.select = False
  428.                
  429.        
  430.             #Create the Layer Weight Node and Reference it as 'layerw_node'        
  431.         layerw_node = material_ghost.node_tree.nodes.new('ShaderNodeLayerWeight')
  432.             #Setting the Location
  433.         layerw_node.location = (0,150)
  434.             #Setting the default color
  435.         layerw_node.inputs[0].default_value = 0.1
  436.             #Deselect the Node
  437.         layerw_node.select = False
  438.        
  439.        
  440.             #Create the Math Node and Reference it as 'math_node'        
  441.         math_node = material_ghost.node_tree.nodes.new('ShaderNodeMath')
  442.             #Setting the Location
  443.         math_node.location = (200,100)
  444.             #Setting the default color
  445.         math_node.inputs[0].default_value = 0.1
  446.             #Deselect the Node
  447.         math_node.select = False
  448.         math_node.hide = True
  449.              
  450.        
  451.             #Create the Mix2 Node and Reference it as 'mix2_node'        
  452.         mix2_node = material_ghost.node_tree.nodes.new('ShaderNodeMixShader')
  453.             #Setting the Location
  454.         mix2_node.location = (800,50)
  455.             #Deselect the Node
  456.         mix2_node.select = False
  457.        
  458.        
  459.        
  460.             #Create the Transparent2 Node and Reference it as 'trans2_node'        
  461.         trans2_node = material_ghost.node_tree.nodes.new('ShaderNodeBsdfTransparent')
  462.             #Setting the Location
  463.         trans2_node.location = (500,-100)
  464.             #Setting the default color
  465.         trans2_node.inputs[0].default_value = (1, 1, 1, 1)
  466.             #Deselect the Node
  467.         trans2_node.select = False
  468.        
  469.      
  470.             #Create the LightPath Node and Reference it as 'light_node'        
  471.         light_node = material_ghost.node_tree.nodes.new('ShaderNodeLightPath')
  472.             #Setting the Location
  473.         light_node.location = (500,500)
  474.             #Deselect the Node
  475.         light_node.select = False
  476.  
  477.        
  478.             #Connecting (known as creating links) between the
  479.         material_ghost.node_tree.links.new(trans_node.outputs[0], mix_node.inputs[1])
  480.         material_ghost.node_tree.links.new(emiss_node.outputs[0], mix_node.inputs[2])
  481.         material_ghost.node_tree.links.new(layerw_node.outputs[0], math_node.inputs[0])
  482.         material_ghost.node_tree.links.new(layerw_node.outputs[1], math_node.inputs[1])
  483.         material_ghost.node_tree.links.new(math_node.outputs[0], mix_node.inputs[0])
  484.         material_ghost.node_tree.links.new(mix_node.outputs[0], mix2_node.inputs[1])
  485.         material_ghost.node_tree.links.new(trans2_node.outputs[0], mix2_node.inputs[2])
  486.         material_ghost.node_tree.links.new(light_node.outputs[11], mix2_node.inputs[0])
  487.         material_ghost.node_tree.links.new(mix2_node.outputs[0], material_output.inputs[0])
  488.            
  489.            
  490.            #Adding Material to the currently selected object
  491.         bpy.context.object.active_material = material_ghost
  492.        
  493.        
  494.         return {'FINISHED'}
  495.    
  496.     def invoke(self, context, event):
  497.         return context.window_manager.invoke_props_dialog(self)
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.    
  505. class WM_OT_hologramOp(bpy.types.Operator):
  506.     """Open the Hologram Dialog box"""
  507.     bl_label = "Hologram"
  508.     bl_idname = "wm.hologramop"
  509.    
  510.     col1 = bpy.props.FloatVectorProperty(name='Color 1',subtype='COLOR_GAMMA',size=4,default=(0.0927682, 1, 0.566671, 1))
  511.    
  512.     col2 = bpy.props.FloatVectorProperty(name='Color 2',subtype='COLOR_GAMMA',size=4,default=(0.381055, 1, 0.697353, 1))
  513.    
  514.    
  515.    
  516.    
  517.    
  518.     def execute(self, context):
  519.        
  520.         c1 = self.col1
  521.         c2 = self.col2
  522.        
  523.             #Create a Shader Material and name it Ghost
  524.         material_hologram = bpy.data.materials.new(name= "Hologram")
  525.             #Use Nodes for this Material
  526.         material_hologram.use_nodes = True
  527.        
  528.             #Create reference to the Material Output
  529.         material_output = material_hologram.node_tree.nodes.get('Material Output')
  530.         material_output.location = (1000,0)
  531.         material_output.select = False
  532.        
  533.         #Select and remove the default Principled Node
  534.         material_hologram.node_tree.nodes.remove(material_hologram.node_tree.nodes.get('Principled BSDF'))
  535.        
  536.      
  537.             #Create the Emission Node and Reference it as 'emiss_node'        
  538.         emiss_node = material_hologram.node_tree.nodes.new('ShaderNodeEmission')
  539.             #Setting the Location
  540.         emiss_node.location = (-200,-90)
  541.             #Setting the default color
  542.         emiss_node.inputs[0].default_value = c1        
  543.             #Setting the Strength Value
  544.         emiss_node.inputs[1].default_value = 2
  545.             #Deselect the Node
  546.         emiss_node.select = False
  547.            
  548.  
  549.             #Create the Transparent Node and Reference it as 'trans1_node'        
  550.         trans1_node = material_hologram.node_tree.nodes.new('ShaderNodeBsdfTransparent')
  551.             #Setting the Location
  552.         trans1_node.location = (-200,10)
  553.             #Setting the default color
  554.         trans1_node.inputs[0].default_value = c2
  555.             #Deselect the Node
  556.         trans1_node.select = False
  557.        
  558.        
  559.             #Create the Mix1 Node and Reference it as 'mix1_node'        
  560.         mix1_node = material_hologram.node_tree.nodes.new('ShaderNodeMixShader')
  561.             #Setting the Location
  562.         mix1_node.location = (400,50)
  563.             #Deselect the Node
  564.         mix1_node.select = False
  565.        
  566.                
  567.             #Create the Layer Weight Node and Reference it as 'layerw_node'        
  568.         layerw_node = material_hologram.node_tree.nodes.new('ShaderNodeLayerWeight')
  569.             #Setting the Location
  570.         layerw_node.location = (0,150)
  571.             #Setting the default color
  572.         layerw_node.inputs[0].default_value = 0.1
  573.             #Deselect the Node
  574.         layerw_node.select = False
  575.        
  576.        
  577.             #Create the Math Node and Reference it as 'math_node'        
  578.         math_node = material_hologram.node_tree.nodes.new('ShaderNodeMath')
  579.             #Setting the Location
  580.         math_node.location = (200,100)
  581.             #Setting the default color
  582.         math_node.inputs[0].default_value = 0.1
  583.             #Deselect the Node
  584.         math_node.select = False
  585.         math_node.hide = True
  586.        
  587.        
  588.             #Create the Mix2 Node and Reference it as 'mix2_node'        
  589.         mix2_node = material_hologram.node_tree.nodes.new('ShaderNodeMixShader')
  590.             #Setting the Location
  591.         mix2_node.location = (600,50)
  592.             #Deselect the Node
  593.         mix2_node.select = False
  594.        
  595.        
  596.        
  597.             #Create the Wireframe Node and Reference it as 'mix_node'        
  598.         wire_node = material_hologram.node_tree.nodes.new('ShaderNodeWireframe')
  599.             #Setting the Location
  600.         wire_node.location = (100,200)
  601.             #Deselect the Node
  602.         wire_node.select = False
  603.             #Enable Use Pixel Size
  604.         wire_node.use_pixel_size = True
  605.             #Enable Use Pixel Size
  606.         wire_node.inputs[0].default_value = 0.05
  607.        
  608.             #create a reroute node
  609.         reroute = material_hologram.node_tree.nodes.new('NodeReroute')
  610.         reroute.location = (-150,-90)
  611.  
  612.        
  613.             #Connecting (known as creating links) between the
  614.         material_hologram.node_tree.links.new(trans1_node.outputs[0], mix1_node.inputs[1])
  615.         material_hologram.node_tree.links.new(emiss_node.outputs[0], reroute.inputs[0])
  616.         material_hologram.node_tree.links.new(reroute.outputs[0], mix1_node.inputs[2])
  617.         material_hologram.node_tree.links.new(reroute.outputs[0], mix2_node.inputs[2])
  618.         material_hologram.node_tree.links.new(layerw_node.outputs[0], math_node.inputs[0])
  619.         material_hologram.node_tree.links.new(layerw_node.outputs[1], math_node.inputs[1])
  620.         material_hologram.node_tree.links.new(math_node.outputs[0], mix1_node.inputs[0])
  621.         material_hologram.node_tree.links.new(mix1_node.outputs[0], mix2_node.inputs[1])
  622.         material_hologram.node_tree.links.new(wire_node.outputs[0], mix2_node.inputs[0])
  623.        
  624.         material_hologram.node_tree.links.new(mix2_node.outputs[0], material_output.inputs[0])
  625.            
  626.            
  627.            #Adding Material to the currently selected object
  628.         bpy.context.object.active_material = material_hologram
  629.        
  630.         return {'FINISHED'}
  631.    
  632.     def invoke(self, context, event):
  633.         return context.window_manager.invoke_props_dialog(self)
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.     #Create a Custom Operator for the Neon Shader
  641. class WM_OT_neonOp(bpy.types.Operator):
  642.     """Open the Neon Dialog box"""
  643.     bl_label = "Neon"
  644.     bl_idname = "wm.neonop"
  645.    
  646.     col = bpy.props.FloatVectorProperty(name='Color',subtype='COLOR_GAMMA',size=4,default=(0.269619, 0.601632, 0.8, 1))
  647.    
  648.     def execute(self, context):
  649.        
  650.         c = self.col
  651.        
  652.             #Creating reference for the "Current Frame"
  653.         cur_frame = bpy.context.scene.frame_current
  654.        
  655.             #Creating a New Shader and calling it Neon
  656.         material_neon = bpy.data.materials.new(name= "Neon")
  657.             #Enabling Use Nodes
  658.         material_neon.use_nodes = True
  659.        
  660.             #Referencing the Node Tree
  661.         tree = material_neon.node_tree
  662.        
  663.             #removing the Principled Node
  664.         material_neon.node_tree.nodes.remove(material_neon.node_tree.nodes.get('Principled BSDF'))
  665.             #Create a reference to the Material Output
  666.         material_output = material_neon.node_tree.nodes.get('Material Output')
  667.             #Set location of node
  668.         material_output.location = (400,0)
  669.        
  670.             #Adding Glass1 Node
  671.         emiss_node = material_neon.node_tree.nodes.new('ShaderNodeEmission')
  672.             #Set location of node
  673.         emiss_node.location = (200,0)
  674.             #Setting the Default Color
  675.         emiss_node.inputs[0].default_value = c
  676.             #Setting the Default Strength Value
  677.         emiss_node.inputs[1].default_value = 1.5
  678.         emiss_node.inputs[1].keyframe_insert("default_value", frame= cur_frame)
  679.        
  680.             #Referencing the Data Path
  681.         data_path = f'nodes["{emiss_node.name}"].inputs[1].default_value'
  682.            
  683.             #Creating a reference for the Fcurves
  684.         fcurves = tree.animation_data.action.fcurves
  685.         fc = fcurves.find(data_path)
  686.         if fc:
  687.             new_mod = fc.modifiers.new('NOISE')
  688.             new_mod.strength = 10
  689.             new_mod.depth = 1
  690.        
  691.        
  692.        
  693.         material_neon.node_tree.links.new(emiss_node.outputs[0], material_output.inputs[0])
  694.            
  695.            
  696.            #Adding Material to the currently selected object
  697.         bpy.context.object.active_material = material_neon
  698.        
  699.        
  700.         return {'FINISHED'}
  701.    
  702.     def invoke(self, context, event):
  703.         return context.window_manager.invoke_props_dialog(self)
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711. class WM_OT_potionOp(bpy.types.Operator):
  712.     """Open the Stylized Potion Dialog box"""
  713.     bl_label = "Stylized Potion"
  714.     bl_idname = "wm.potionop"
  715.    
  716.    
  717.    
  718.     col1 = bpy.props.FloatVectorProperty(name='Color 1',subtype='COLOR_GAMMA',size=4,default=(1, 0, 0.0018755, 1))
  719.    
  720.     col2 = bpy.props.FloatVectorProperty(name='Color 2',subtype='COLOR_GAMMA',size=4,default=(0.255103, 0, 0.000564289, 1))
  721.    
  722.     start = bpy.props.IntProperty(name= "Start Frame", default = 0)
  723.     end = bpy.props.IntProperty(name= "End Frame", default = 250)
  724.    
  725.    
  726.    
  727.    
  728.    
  729.     def execute(self, context):
  730.        
  731.         s = self.start
  732.         e = self.end
  733.         c1 = self.col1
  734.         c2 = self.col2
  735.          
  736.        
  737.        
  738.             #Creating a New Shader and calling it Diamond
  739.         material_potion = bpy.data.materials.new(name= "Stylized Potion")
  740.             #Enabling Use Nodes
  741.         material_potion.use_nodes = True
  742.        
  743.         tree = material_potion.node_tree
  744.        
  745.             #Create a reference to the Principled Shader
  746.         prin_node = material_potion.node_tree.nodes.get('Principled BSDF')
  747.             #set location of node
  748.         prin_node.location = (200,0)
  749.             #setting default values
  750.         prin_node.inputs[0].default_value = (0.8, 0.000897912, 0, 1)
  751.         prin_node.inputs[3].default_value = (0.8, 0.1332, 0.0936454, 1)
  752.         prin_node.inputs[7].default_value = 0.076
  753.         prin_node.inputs[15].default_value = 0.947
  754.        
  755.             #Create a reference to the Material Output
  756.         material_output = material_potion.node_tree.nodes.get('Material Output')
  757.             #Set location of node
  758.         material_output.location = (500,0)
  759.        
  760.             #adding rgb1 Node
  761.         rgb1_node = material_potion.node_tree.nodes.new('ShaderNodeRGB')
  762.             #set location of the node
  763.         rgb1_node.location = (-200,0)
  764.             #set default color
  765.         rgb1_node.outputs[0].default_value = c1
  766.        
  767.             #adding rgb2 Node
  768.         rgb2_node = material_potion.node_tree.nodes.new('ShaderNodeRGB')
  769.             #set location of the node
  770.         rgb2_node.location = (-200,-200)
  771.             #set default color
  772.         rgb2_node.outputs[0].default_value = c2
  773.        
  774.             #adding Mix node
  775.         mix_node = material_potion.node_tree.nodes.new('ShaderNodeMixRGB')
  776.             #set location of the node
  777.         mix_node.location = (0,0)
  778.        
  779.        
  780.        
  781.         noise_node = material_potion.node_tree.nodes.new('ShaderNodeTexNoise')
  782.         noise_node.location = (-500, 200)
  783.         noise_node.inputs[2].default_value = 5
  784.         noise_node.inputs[3].default_value = 0.2
  785.         noise_node.inputs[3].keyframe_insert("default_value", frame= s-150)
  786.         noise_node.inputs[3].default_value = 1.2
  787.         noise_node.inputs[3].keyframe_insert("default_value", frame= e+50)
  788.        
  789.        
  790.        
  791.        
  792.         ramp_node = material_potion.node_tree.nodes.new('ShaderNodeValToRGB')
  793.         ramp_node.location = (-300, 200)
  794.         ramp_node.color_ramp.elements[0].position = 0.454
  795.         ramp_node.color_ramp.elements[1].position = 0.522
  796.        
  797.        
  798.        
  799.            
  800.             #creating a reference for the links
  801.         link = material_potion.node_tree.links.new
  802.        
  803.             #Link the Nodes
  804.         link(rgb1_node.outputs[0], mix_node.inputs[1])
  805.         link(rgb2_node.outputs[0], mix_node.inputs[2])
  806.         link(noise_node.outputs[0], ramp_node.inputs[0])
  807.         link(ramp_node.outputs[0], mix_node.inputs[0])
  808.         link(mix_node.outputs[0], prin_node.inputs[0])
  809.         link(prin_node.outputs[0], material_output.inputs[0])
  810.        
  811.            
  812.             #Adding Material to the currently selected object
  813.         bpy.context.object.active_material = material_potion
  814.        
  815.        
  816.         return {'FINISHED'}
  817.    
  818.     def invoke(self, context, event):
  819.         return context.window_manager.invoke_props_dialog(self)
  820.    
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.     #registering classes
  862. def register():
  863.     bpy.utils.register_class(ShaderMainPanel)
  864.     bpy.utils.register_class(SubPanelMetals)
  865.     bpy.utils.register_class(SubPanelPreciousMetals)
  866.     bpy.utils.register_class(SubPanelStylized)
  867.     bpy.utils.register_class(SHADER_OT_DIAMOND)
  868.     bpy.utils.register_class(SHADER_OT_GOLD)
  869.     bpy.utils.register_class(SHADER_OT_SILVER)
  870.     bpy.utils.register_class(SHADER_OT_COPPER)
  871.     bpy.utils.register_class(WM_OT_ghostOp)
  872.     bpy.utils.register_class(WM_OT_hologramOp)
  873.     bpy.utils.register_class(WM_OT_neonOp)
  874.     bpy.utils.register_class(WM_OT_potionOp)
  875.    
  876.    
  877.    
  878.    
  879.    
  880.    
  881.  
  882.     #unregistering classes
  883. def unregister():
  884.     bpy.utils.unregister_class(ShaderMainPanel)
  885.     bpy.utils.unregister_class(SubPanelMetals)
  886.     bpy.utils.unregister_class(SubPanelPreciousMetals)
  887.     bpy.utils.unregister_class(SubPanelStylized)
  888.     bpy.utils.unregister_class(SHADER_OT_DIAMOND)
  889.     bpy.utils.unregister_class(SHADER_OT_GOLD)
  890.     bpy.utils.unregister_class(SHADER_OT_SILVER)
  891.     bpy.utils.unregister_class(SHADER_OT_COPPER)
  892.     bpy.utils.unregister_class(WM_OT_ghostOp)
  893.     bpy.utils.unregister_class(WM_OT_hologramOp)
  894.     bpy.utils.unregister_class(WM_OT_neonOp)
  895.     bpy.utils.unregister_class(WM_OT_potionOp)
  896.  
  897.     #Needed in order to run the script in the editor
  898. if __name__ == "__main__":
  899.     register()
Add Comment
Please, Sign In to add comment