Advertisement
Guest User

ShaderLibraryAddon.py

a guest
Jan 26th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 24.09 KB | None | 0 0
  1. bl_info = {
  2.     "name": "Shader Library",
  3.     "author": "Darkfall",
  4.     "version": (1, 0),
  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.     #creat 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('shader.ghost_operator', icon= 'GHOST_ENABLED')
  99.         row.operator('shader.hologram_operator', icon= 'USER')
  100.         row = layout.row()
  101.  
  102.  
  103.  
  104.     #Create a Custom Operator for the Diamond Shader
  105. class SHADER_OT_DIAMOND(bpy.types.Operator):
  106.     """Add the Diamond Shader to your selected Object."""
  107.     bl_label = "Diamond"
  108.     bl_idname = 'shader.diamond_operator'
  109.    
  110.    
  111.     def execute(self, context):
  112.        
  113.             #Creating a New Shader and calling it Diamond
  114.         material_diamond = bpy.data.materials.new(name= "Diamond")
  115.             #Enabling Use Nodes
  116.         material_diamond.use_nodes = True
  117.             #removing the Principled Node
  118.         material_diamond.node_tree.nodes.remove(material_diamond.node_tree.nodes.get('Principled BSDF'))
  119.             #Create a reference to the Material Output
  120.         material_output = material_diamond.node_tree.nodes.get('Material Output')
  121.             #Set location of node
  122.         material_output.location = (400,0)
  123.        
  124.             #Adding Glass1 Node
  125.         glass1_node = material_diamond.node_tree.nodes.new('ShaderNodeBsdfGlass')
  126.             #Set location of node
  127.         glass1_node.location = (-600,0)
  128.             #Setting the Default Color
  129.         glass1_node.inputs[0].default_value = (1, 0, 0, 1)
  130.             #Setting the Default IOR Value
  131.         glass1_node.inputs[2].default_value = 1.446
  132.        
  133.        
  134.             #Adding Glass2 Node
  135.         glass2_node = material_diamond.node_tree.nodes.new('ShaderNodeBsdfGlass')
  136.             #Set location of node
  137.         glass2_node.location = (-600,-150)
  138.             #Setting the Default Color
  139.         glass2_node.inputs[0].default_value = (0, 1, 0, 1)
  140.             #Setting the Default IOR Value
  141.         glass2_node.inputs[2].default_value = 1.450
  142.        
  143.        
  144.             #Adding Glass3 Node
  145.         glass3_node = material_diamond.node_tree.nodes.new('ShaderNodeBsdfGlass')
  146.             #Set location of node
  147.         glass3_node.location = (-600,-300)
  148.             #Setting the Default Color
  149.         glass3_node.inputs[0].default_value = (0, 0, 1, 1)
  150.             #Setting the Default IOR Value
  151.         glass3_node.inputs[2].default_value = 1.545
  152.        
  153.        
  154.        
  155.             #Create the Add Shader Node and Reference it as 'Add1'        
  156.         add1_node = material_diamond.node_tree.nodes.new('ShaderNodeAddShader')
  157.             #Setting the Location
  158.         add1_node.location = (-400,-50)
  159.             #Setting the Label
  160.         add1_node.label = "Add 1"
  161.             #Minimizes the Node
  162.         add1_node.hide = True
  163.             #Deselect the Node
  164.         add1_node.select = False
  165.        
  166.             #Create the Add Shader Node and Reference it as 'Add2'        
  167.         add2_node = material_diamond.node_tree.nodes.new('ShaderNodeAddShader')
  168.             #Setting the Location
  169.         add2_node.location = (-100,0)
  170.             #Setting the Label
  171.         add2_node.label = "Add 2"
  172.             #Minimizes the Node
  173.         add2_node.hide = True
  174.         #Deselect the Node
  175.         add2_node.select = False
  176.        
  177.             #Create the Glass Node and Reference it as 'glass4'        
  178.         glass4_node = material_diamond.node_tree.nodes.new('ShaderNodeBsdfGlass')
  179.             #Setting the Location
  180.         glass4_node.location = (-150,-150)
  181.             #Setting the default color
  182.         glass4_node.inputs[0].default_value = (1, 1, 1, 1)
  183.             #Setting the default IOR
  184.         glass4_node.inputs[2].default_value = 1.450
  185.             #Deselect the Node
  186.         glass4_node.select = False
  187.        
  188.             #Create the Mix Shader Node and Reference it as 'Mix1'        
  189.         mix1_node = material_diamond.node_tree.nodes.new('ShaderNodeMixShader')
  190.             #Setting the Location
  191.         mix1_node.location = (200,0)
  192.             #Deselect the Node
  193.         mix1_node.select = False
  194.        
  195.             #Creating Links between the Nodes
  196.         material_diamond.node_tree.links.new(glass1_node.outputs[0], add1_node.inputs[0])
  197.         material_diamond.node_tree.links.new(glass2_node.outputs[0], add1_node.inputs[1])
  198.         material_diamond.node_tree.links.new(add1_node.outputs[0], add2_node.inputs[0])
  199.         material_diamond.node_tree.links.new(glass3_node.outputs[0], add2_node.inputs[1])
  200.         material_diamond.node_tree.links.new(add2_node.outputs[0], mix1_node.inputs[1])
  201.         material_diamond.node_tree.links.new(glass4_node.outputs[0], mix1_node.inputs[2])
  202.         material_diamond.node_tree.links.new(mix1_node.outputs[0], material_output.inputs[0])
  203.            
  204.             #Adding Material to the currently selected object
  205.         bpy.context.object.active_material = material_diamond
  206.        
  207.         return {'FINISHED'}
  208.        
  209.        
  210.        
  211.        
  212.     #Operator for the Gold (basic) Shader
  213. class SHADER_OT_GOLD(bpy.types.Operator):
  214.     """Add the Basic Gold Shader to your selected Object."""
  215.     bl_label = "Gold"
  216.     bl_idname = 'shader.gold_operator'
  217.    
  218.     def execute(self, context):
  219.        
  220.             #Create a Shader Material and name it Gold
  221.         material_gold = bpy.data.materials.new(name= "Gold")
  222.             #Use Nodes for this Material
  223.         material_gold.use_nodes = True
  224.        
  225.             #Create reference to the Material Output
  226.         material_output = material_gold.node_tree.nodes.get('Material Output')
  227.         material_output.location = (600,0)
  228.         material_output.select = False
  229.        
  230.        
  231.             #Create the RGB Node and Reference it as 'rgb_node'        
  232.         rgb_node = material_gold.node_tree.nodes.new('ShaderNodeRGB')
  233.             #Setting the Location
  234.         rgb_node.location = (0,-100)
  235.             #Setting the default color
  236.         rgb_node.outputs[0].default_value = (1, 0.766, 0.336, 1)
  237.             #Deselect the Node
  238.         rgb_node.select = False
  239.             #Minimize the Node
  240.         rgb_node.hide = True
  241.        
  242.        
  243.             #Create reference to the Principled Node
  244.         principled = material_gold.node_tree.nodes.get('Principled BSDF')
  245.         principled.location = (200,0)
  246.         principled.select = False
  247.         principled.inputs[4].default_value = 1.0
  248.        
  249.        
  250.             #Connecting (known as creating links) between the
  251.         material_gold.node_tree.links.new(rgb_node.outputs[0], principled.inputs[0])
  252.            
  253.            
  254.             #Adding Material to the currently selected object
  255.         bpy.context.object.active_material = material_gold
  256.            
  257.         return {'FINISHED'}
  258.  
  259.  
  260.  
  261.  
  262.     #Operator for the Silver (basic) Shader
  263. class SHADER_OT_SILVER(bpy.types.Operator):
  264.     """Add the Basic Silver Shader to your selected Object."""
  265.     bl_label = "Silver"
  266.     bl_idname = 'shader.silver_operator'
  267.    
  268.     def execute(self, context):
  269.        
  270.             #Create a Shader Material and name it Silver
  271.         material_silver = bpy.data.materials.new(name= "Silver")
  272.             #Use Nodes for this Material
  273.         material_silver.use_nodes = True
  274.        
  275.             #Create reference to the Material Output
  276.         material_output = material_silver.node_tree.nodes.get('Material Output')
  277.         material_output.location = (600,0)
  278.         material_output.select = False
  279.        
  280.      
  281.             #Create the RGB Node and Reference it as 'rgb_node'        
  282.         rgb_node = material_silver.node_tree.nodes.new('ShaderNodeRGB')
  283.             #Setting the Location
  284.         rgb_node.location = (0,-100)
  285.             #Setting the default color
  286.         rgb_node.outputs[0].default_value = (0.972, 0.960, 0.915, 1)
  287.             #Deselect the Node
  288.         rgb_node.select = False
  289.             #Minimize the Node
  290.         rgb_node.hide = True
  291.        
  292.        
  293.             #Create reference to the Principled Node
  294.         principled = material_silver.node_tree.nodes.get('Principled BSDF')
  295.         principled.location = (200,0)
  296.         principled.select = False
  297.         principled.inputs[4].default_value = 1.0
  298.        
  299.      
  300.             #Connecting (known as creating links) between the
  301.         material_silver.node_tree.links.new(rgb_node.outputs[0], principled.inputs[0])
  302.            
  303.            
  304.             #Adding Material to the currently selected object
  305.         bpy.context.object.active_material = material_silver
  306.            
  307.         return {'FINISHED'}
  308.  
  309.  
  310.  
  311.  
  312.     #Operator for the Copper (basic) Shader
  313. class SHADER_OT_COPPER(bpy.types.Operator):
  314.     """Add the Basic Copper Shader to your selected Object."""
  315.     bl_label = "Copper"
  316.     bl_idname = 'shader.copper_operator'
  317.    
  318.     def execute(self, context):
  319.        
  320.             #Create a Shader Material and name it Copper
  321.         material_copper = bpy.data.materials.new(name= "Copper")
  322.             #Use Nodes for this Material
  323.         material_copper.use_nodes = True
  324.        
  325.             #Create reference to the Material Output
  326.         material_output = material_copper.node_tree.nodes.get('Material Output')
  327.         material_output.location = (600,0)
  328.         material_output.select = False
  329.        
  330.        
  331.             #Create the RGB Node and Reference it as 'rgb_node'        
  332.         rgb_node = material_copper.node_tree.nodes.new('ShaderNodeRGB')
  333.             #Setting the Location
  334.         rgb_node.location = (0,-100)
  335.             #Setting the default color
  336.         rgb_node.outputs[0].default_value = (0.955, 0.637, 0.538, 1)
  337.             #Deselect the Node
  338.         rgb_node.select = False
  339.             #Minimize the Node
  340.         rgb_node.hide = True
  341.        
  342.        
  343.             #Create reference to the Principled Node
  344.         principled = material_copper.node_tree.nodes.get('Principled BSDF')
  345.         principled.location = (200,0)
  346.         principled.select = False
  347.         principled.inputs[4].default_value = 1.0
  348.        
  349.        
  350.             #Connecting (known as creating links) between the
  351.         material_copper.node_tree.links.new(rgb_node.outputs[0], principled.inputs[0])
  352.            
  353.            
  354.            #Adding Material to the currently selected object
  355.         bpy.context.object.active_material = material_copper
  356.            
  357.         return {'FINISHED'}
  358.    
  359.    
  360.    
  361.    
  362.     #Operator for the Ghost Shader
  363. class SHADER_OT_GHOST(bpy.types.Operator):
  364.     """Add the Ghost Shader to your selected Object."""
  365.     bl_label = "Ghost"
  366.     bl_idname = 'shader.ghost_operator'
  367.    
  368.     def execute(self, context):
  369.        
  370.             #Create a Shader Material and name it Ghost
  371.         material_ghost = bpy.data.materials.new(name= "Ghost")
  372.             #Use Nodes for this Material
  373.         material_ghost.use_nodes = True
  374.        
  375.             #Create reference to the Material Output
  376.         material_output = material_ghost.node_tree.nodes.get('Material Output')
  377.         material_output.location = (1000,0)
  378.         material_output.select = False
  379.        
  380.         #Select and remove the default Principled Node
  381.         material_ghost.node_tree.nodes.remove(material_ghost.node_tree.nodes.get('Principled BSDF'))
  382.        
  383.        
  384.             #Create the Emission Node and Reference it as 'emiss_node'        
  385.         emiss_node = material_ghost.node_tree.nodes.new('ShaderNodeEmission')
  386.             #Setting the Location
  387.         emiss_node.location = (-200,-90)
  388.             #Setting the default color
  389.         emiss_node.inputs[0].default_value = (0.224322, 0.812741, 1, 1)
  390.         emiss_node.inputs[1].default_value = 2
  391.  
  392.             #Deselect the Node
  393.         emiss_node.select = False
  394.            
  395.  
  396.             #Create the Transparent Node and Reference it as 'trans_node'        
  397.         trans_node = material_ghost.node_tree.nodes.new('ShaderNodeBsdfTransparent')
  398.             #Setting the Location
  399.         trans_node.location = (-200,10)
  400.             #Setting the default color
  401.         trans_node.inputs[0].default_value = (0.137478, 0.345533, 1, 1)
  402.             #Deselect the Node
  403.         trans_node.select = False
  404.        
  405.        
  406.             #Create the Mix Node and Reference it as 'mix_node'        
  407.         mix_node = material_ghost.node_tree.nodes.new('ShaderNodeMixShader')
  408.             #Setting the Location
  409.         mix_node.location = (400,50)
  410.             #Deselect the Node
  411.         mix_node.select = False
  412.                
  413.        
  414.             #Create the Layer Weight Node and Reference it as 'layerw_node'        
  415.         layerw_node = material_ghost.node_tree.nodes.new('ShaderNodeLayerWeight')
  416.             #Setting the Location
  417.         layerw_node.location = (0,150)
  418.             #Setting the default color
  419.         layerw_node.inputs[0].default_value = 0.1
  420.             #Deselect the Node
  421.         layerw_node.select = False
  422.        
  423.        
  424.             #Create the Math Node and Reference it as 'math_node'        
  425.         math_node = material_ghost.node_tree.nodes.new('ShaderNodeMath')
  426.             #Setting the Location
  427.         math_node.location = (200,100)
  428.             #Setting the default color
  429.         math_node.inputs[0].default_value = 0.1
  430.             #Deselect the Node
  431.         math_node.select = False
  432.         math_node.hide = True
  433.              
  434.        
  435.             #Create the Mix2 Node and Reference it as 'mix2_node'        
  436.         mix2_node = material_ghost.node_tree.nodes.new('ShaderNodeMixShader')
  437.             #Setting the Location
  438.         mix2_node.location = (800,50)
  439.             #Deselect the Node
  440.         mix2_node.select = False
  441.        
  442.        
  443.        
  444.             #Create the Transparent2 Node and Reference it as 'trans2_node'        
  445.         trans2_node = material_ghost.node_tree.nodes.new('ShaderNodeBsdfTransparent')
  446.             #Setting the Location
  447.         trans2_node.location = (500,-100)
  448.             #Setting the default color
  449.         trans2_node.inputs[0].default_value = (1, 1, 1, 1)
  450.             #Deselect the Node
  451.         trans2_node.select = False
  452.        
  453.      
  454.             #Create the LightPath Node and Reference it as 'light_node'        
  455.         light_node = material_ghost.node_tree.nodes.new('ShaderNodeLightPath')
  456.             #Setting the Location
  457.         light_node.location = (500,500)
  458.             #Deselect the Node
  459.         light_node.select = False
  460.  
  461.        
  462.             #Connecting (known as creating links) between the
  463.         material_ghost.node_tree.links.new(trans_node.outputs[0], mix_node.inputs[1])
  464.         material_ghost.node_tree.links.new(emiss_node.outputs[0], mix_node.inputs[2])
  465.         material_ghost.node_tree.links.new(layerw_node.outputs[0], math_node.inputs[0])
  466.         material_ghost.node_tree.links.new(layerw_node.outputs[1], math_node.inputs[1])
  467.         material_ghost.node_tree.links.new(math_node.outputs[0], mix_node.inputs[0])
  468.         material_ghost.node_tree.links.new(mix_node.outputs[0], mix2_node.inputs[1])
  469.         material_ghost.node_tree.links.new(trans2_node.outputs[0], mix2_node.inputs[2])
  470.         material_ghost.node_tree.links.new(light_node.outputs[11], mix2_node.inputs[0])
  471.         material_ghost.node_tree.links.new(mix2_node.outputs[0], material_output.inputs[0])
  472.            
  473.            
  474.            #Adding Material to the currently selected object
  475.         bpy.context.object.active_material = material_ghost
  476.            
  477.         return {'FINISHED'}
  478.  
  479.  
  480.  
  481.  
  482.     #Operator for the Hologram Shader
  483. class SHADER_OT_HOLOGRAM(bpy.types.Operator):
  484.     """Add the Hologram Shader to your selected Object."""
  485.     bl_label = "Hologram"
  486.     bl_idname = 'shader.hologram_operator'
  487.    
  488.     def execute(self, context):
  489.        
  490.             #Create a Shader Material and name it Ghost
  491.         material_hologram = bpy.data.materials.new(name= "Hologram")
  492.             #Use Nodes for this Material
  493.         material_hologram.use_nodes = True
  494.        
  495.             #Create reference to the Material Output
  496.         material_output = material_hologram.node_tree.nodes.get('Material Output')
  497.         material_output.location = (1000,0)
  498.         material_output.select = False
  499.        
  500.         #Select and remove the default Principled Node
  501.         material_hologram.node_tree.nodes.remove(material_hologram.node_tree.nodes.get('Principled BSDF'))
  502.        
  503.      
  504.             #Create the Emission Node and Reference it as 'emiss_node'        
  505.         emiss_node = material_hologram.node_tree.nodes.new('ShaderNodeEmission')
  506.             #Setting the Location
  507.         emiss_node.location = (-200,-90)
  508.             #Setting the default color
  509.         emiss_node.inputs[0].default_value = (0.0927682, 1, 0.566671, 1)        
  510.             #Setting the Strength Value
  511.         emiss_node.inputs[1].default_value = 2
  512.             #Deselect the Node
  513.         emiss_node.select = False
  514.            
  515.  
  516.             #Create the Transparent Node and Reference it as 'trans1_node'        
  517.         trans1_node = material_hologram.node_tree.nodes.new('ShaderNodeBsdfTransparent')
  518.             #Setting the Location
  519.         trans1_node.location = (-200,10)
  520.             #Setting the default color
  521.         trans1_node.inputs[0].default_value = (0.381055, 1, 0.697353, 1)
  522.             #Deselect the Node
  523.         trans1_node.select = False
  524.        
  525.        
  526.             #Create the Mix1 Node and Reference it as 'mix1_node'        
  527.         mix1_node = material_hologram.node_tree.nodes.new('ShaderNodeMixShader')
  528.             #Setting the Location
  529.         mix1_node.location = (400,50)
  530.             #Deselect the Node
  531.         mix1_node.select = False
  532.        
  533.                
  534.             #Create the Layer Weight Node and Reference it as 'layerw_node'        
  535.         layerw_node = material_hologram.node_tree.nodes.new('ShaderNodeLayerWeight')
  536.             #Setting the Location
  537.         layerw_node.location = (0,150)
  538.             #Setting the default color
  539.         layerw_node.inputs[0].default_value = 0.1
  540.             #Deselect the Node
  541.         layerw_node.select = False
  542.        
  543.        
  544.             #Create the Math Node and Reference it as 'math_node'        
  545.         math_node = material_hologram.node_tree.nodes.new('ShaderNodeMath')
  546.             #Setting the Location
  547.         math_node.location = (200,100)
  548.             #Setting the default color
  549.         math_node.inputs[0].default_value = 0.1
  550.             #Deselect the Node
  551.         math_node.select = False
  552.         math_node.hide = True
  553.        
  554.        
  555.             #Create the Mix2 Node and Reference it as 'mix2_node'        
  556.         mix2_node = material_hologram.node_tree.nodes.new('ShaderNodeMixShader')
  557.             #Setting the Location
  558.         mix2_node.location = (600,50)
  559.             #Deselect the Node
  560.         mix2_node.select = False
  561.        
  562.        
  563.        
  564.             #Create the Wireframe Node and Reference it as 'mix_node'        
  565.         wire_node = material_hologram.node_tree.nodes.new('ShaderNodeWireframe')
  566.             #Setting the Location
  567.         wire_node.location = (100,200)
  568.             #Deselect the Node
  569.         wire_node.select = False
  570.             #Enable Use Pixel Size
  571.         wire_node.use_pixel_size = True
  572.             #Enable Use Pixel Size
  573.         wire_node.inputs[0].default_value = 0.05
  574.        
  575.             #create a reroute node
  576.         reroute = material_hologram.node_tree.nodes.new('NodeReroute')
  577.         reroute.location = (-150,-90)
  578.  
  579.        
  580.             #Connecting (known as creating links) between the
  581.         material_hologram.node_tree.links.new(trans1_node.outputs[0], mix1_node.inputs[1])
  582.         material_hologram.node_tree.links.new(emiss_node.outputs[0], reroute.inputs[0])
  583.         material_hologram.node_tree.links.new(reroute.outputs[0], mix1_node.inputs[2])
  584.         material_hologram.node_tree.links.new(reroute.outputs[0], mix2_node.inputs[2])
  585.         material_hologram.node_tree.links.new(layerw_node.outputs[0], math_node.inputs[0])
  586.         material_hologram.node_tree.links.new(layerw_node.outputs[1], math_node.inputs[1])
  587.         material_hologram.node_tree.links.new(math_node.outputs[0], mix1_node.inputs[0])
  588.         material_hologram.node_tree.links.new(mix1_node.outputs[0], mix2_node.inputs[1])
  589.         material_hologram.node_tree.links.new(wire_node.outputs[0], mix2_node.inputs[0])
  590.        
  591.         material_hologram.node_tree.links.new(mix2_node.outputs[0], material_output.inputs[0])
  592.            
  593.            
  594.            #Adding Material to the currently selected object
  595.         bpy.context.object.active_material = material_hologram
  596.            
  597.         return {'FINISHED'}
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.     #registering classes
  605. def register():
  606.     bpy.utils.register_class(ShaderMainPanel)
  607.     bpy.utils.register_class(SubPanelMetals)
  608.     bpy.utils.register_class(SubPanelPreciousMetals)
  609.     bpy.utils.register_class(SubPanelStylized)
  610.     bpy.utils.register_class(SHADER_OT_DIAMOND)
  611.     bpy.utils.register_class(SHADER_OT_GOLD)
  612.     bpy.utils.register_class(SHADER_OT_SILVER)
  613.     bpy.utils.register_class(SHADER_OT_COPPER)
  614.     bpy.utils.register_class(SHADER_OT_GHOST)
  615.     bpy.utils.register_class(SHADER_OT_HOLOGRAM)
  616.    
  617.    
  618.    
  619.    
  620.  
  621.     #unregistering classes
  622. def unregister():
  623.     bpy.utils.unregister_class(ShaderMainPanel)
  624.     bpy.utils.unregister_class(SubPanelMetals)
  625.     bpy.utils.unregister_class(SubPanelPreciousMetals)
  626.     bpy.utils.unregister_class(SubPanelStylized)
  627.     bpy.utils.unregister_class(SHADER_OT_DIAMOND)
  628.     bpy.utils.unregister_class(SHADER_OT_GOLD)
  629.     bpy.utils.unregister_class(SHADER_OT_SILVER)
  630.     bpy.utils.unregister_class(SHADER_OT_COPPER)
  631.     bpy.utils.unregister_class(SHADER_OT_GHOST)
  632.     bpy.utils.unregister_class(SHADER_OT_HOLOGRAM)
  633.  
  634.     #Needed in order to run the script in the editor
  635. if __name__ == "__main__":
  636.     register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement