Skip to content

Commit

Permalink
Update for blender 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LazyDodo committed Jan 15, 2024
1 parent c7db418 commit 7a8606e
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 78 deletions.
45 changes: 39 additions & 6 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"LazyDodo, "
"Secrop"
),
"version": (0, 0, 1,4),
"version": (0, 0, 1,5),
"blender": (2, 80, 0),
"location": "Nodes > Add nodes",
"description": "Brick Tricks Cycles Nodes",
Expand All @@ -24,13 +24,15 @@

import bpy,nodeitems_utils
from nodeitems_utils import NodeCategory, NodeItem

from bpy.types import Menu
from bl_ui import node_add_menu

class ExtraNodesCategory(NodeCategory):
@classmethod
def poll(cls, context):
return (context.space_data.tree_type == 'ShaderNodeTree' and
context.scene.render.engine in ['BLENDER_EEVEE', 'CYCLES'])

node_categories = [
ExtraNodesCategory("SH_BRICK_TRIKS", "BrickTricks", items=[
NodeItem("ShaderNodeuv_map_tile_pattern_1"),
Expand All @@ -44,8 +46,35 @@ def poll(cls, context):
NodeItem("ShaderNodebonus_hexagon"),
]),
]


class NODE_MT_category_shader_bricktricks(Menu):
bl_idname = "NODE_MT_category_shader_bricktricks"
bl_label = "Brick Tricks"

def draw(self, context):
layout = self.layout

node_add_menu.add_node_type(layout, "ShaderNodeuv_map_tile_pattern_1")
node_add_menu.add_node_type(layout, "ShaderNodeuv_map_tile_pattern_2")
node_add_menu.add_node_type(layout, "ShaderNodeuv_map_diamond")
node_add_menu.add_node_type(layout, "ShaderNodeuv_map_brick_wall")
node_add_menu.add_node_type(layout, "ShaderNodeuv_map_swirl")
node_add_menu.add_node_type(layout, "ShaderNodebrick_rounded_corner")
node_add_menu.add_node_type(layout, "ShaderNodebrick_square_corner")
node_add_menu.add_node_type(layout, "ShaderNodeuv_map_rotate")
node_add_menu.add_node_type(layout, "ShaderNodebonus_hexagon")
node_add_menu.draw_assets_for_catalog(layout, self.bl_label)

def bricktricks_draw(self, context):
layout = self.layout
layout.menu("NODE_MT_category_shader_bricktricks")

def register():
if bpy.app.version >= (4, 0, 0):
bpy.utils.register_class(NODE_MT_category_shader_bricktricks)
bpy.types.NODE_MT_shader_node_add_all.append(bricktricks_draw)
else:
nodeitems_utils.register_node_categories("BRICK_TRICKS_NODES", node_categories)
bpy.utils.register_class(ShaderNodebonus_hexagon)
bpy.utils.register_class(ShaderNodebrick_rounded_corner)
bpy.utils.register_class(ShaderNodebrick_square_corner)
Expand All @@ -55,11 +84,9 @@ def register():
bpy.utils.register_class(ShaderNodeuv_map_tile_pattern_1)
bpy.utils.register_class(ShaderNodeuv_map_tile_pattern_2)
bpy.utils.register_class(ShaderNodeuv_map_diamond)
nodeitems_utils.register_node_categories("BRICK_TRICKS_NODES", node_categories)


def unregister():
nodeitems_utils.unregister_node_categories("BRICK_TRICKS_NODES")
bpy.utils.unregister_class(ShaderNodebonus_hexagon)
bpy.utils.unregister_class(ShaderNodebrick_rounded_corner)
bpy.utils.unregister_class(ShaderNodebrick_square_corner)
Expand All @@ -69,6 +96,12 @@ def unregister():
bpy.utils.unregister_class(ShaderNodeuv_map_tile_pattern_1)
bpy.utils.unregister_class(ShaderNodeuv_map_tile_pattern_2)
bpy.utils.unregister_class(ShaderNodeuv_map_diamond)
if bpy.app.version >= (4, 0, 0):
bpy.types.NODE_MT_shader_node_add_all.remove(bricktricks_draw)
bpy.utils.unregister_class(NODE_MT_category_shader_bricktricks)
else:
nodeitems_utils.unregister_node_categories("BRICK_TRICKS_NODES")

if __name__ == "__main__":
register()

22 changes: 14 additions & 8 deletions bonus_hexagon_addin.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def createNodetree(self, name) :
self.addNode('ShaderNodeMath', { 'name':'Node134' ,'operation':'DIVIDE','use_clamp':1 })
#Sockets
self.addSocket(False, 'NodeSocketVector', 'Vector')
self.addSocket(False, 'NodeSocketFloatFactor', 'HAS_Vector')
self.addSocket(False, 'NodeSocketFloat', 'HAS_Vector')
self.addSocket(False, 'NodeSocketFloat', 'scale')
self.addSocket(False, 'NodeSocketFloat', 'feather')
self.addSocket(True, 'NodeSocketFloat', 'Value')
Expand Down Expand Up @@ -358,13 +358,19 @@ def getNodetree(self, name):
self.node_tree=bpy.data.node_groups[name]

def addSocket(self, is_output, sockettype, name):
#for now duplicated socket names are not allowed
if is_output==True:
if self.node_tree.nodes['GroupOutput'].inputs.find(name)==-1:
socket=self.node_tree.outputs.new(sockettype, name)
elif is_output==False:
if self.node_tree.nodes['GroupInput'].outputs.find(name)==-1:
socket=self.node_tree.inputs.new(sockettype, name)
if bpy.app.version >= (4, 0, 0):
if is_output==True:
socket = self.node_tree.interface.new_socket(name, in_out='OUTPUT', socket_type=sockettype)
else:
socket = self.node_tree.interface.new_socket(name, in_out='INPUT', socket_type=sockettype)
else:
#for now duplicated socket names are not allowed
if is_output==True:
if self.node_tree.nodes['GroupOutput'].inputs.find(name)==-1:
socket=self.node_tree.outputs.new(sockettype, name)
elif is_output==False:
if self.node_tree.nodes['GroupInput'].outputs.find(name)==-1:
socket=self.node_tree.inputs.new(sockettype, name)
return socket

def addNode(self, nodetype, attrs):
Expand Down
22 changes: 14 additions & 8 deletions brick_rounded_corner_addin.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def createNodetree(self, name) :
self.addNode('ShaderNodeMath', { 'name':'Node48' ,'operation':'DIVIDE','use_clamp':1 })
#Sockets
self.addSocket(False, 'NodeSocketVector', 'Vector')
self.addSocket(False, 'NodeSocketFloatFactor', 'HAS_Vector')
self.addSocket(False, 'NodeSocketFloat', 'HAS_Vector')
self.addSocket(False, 'NodeSocketFloat', 'brick_width')
self.addSocket(False, 'NodeSocketFloat', 'brick_height')
self.addSocket(False, 'NodeSocketFloat', 'border')
Expand Down Expand Up @@ -177,13 +177,19 @@ def getNodetree(self, name):
self.node_tree=bpy.data.node_groups[name]

def addSocket(self, is_output, sockettype, name):
#for now duplicated socket names are not allowed
if is_output==True:
if self.node_tree.nodes['GroupOutput'].inputs.find(name)==-1:
socket=self.node_tree.outputs.new(sockettype, name)
elif is_output==False:
if self.node_tree.nodes['GroupInput'].outputs.find(name)==-1:
socket=self.node_tree.inputs.new(sockettype, name)
if bpy.app.version >= (4, 0, 0):
if is_output==True:
socket = self.node_tree.interface.new_socket(name, in_out='OUTPUT', socket_type=sockettype)
else:
socket = self.node_tree.interface.new_socket(name, in_out='INPUT', socket_type=sockettype)
else:
#for now duplicated socket names are not allowed
if is_output==True:
if self.node_tree.nodes['GroupOutput'].inputs.find(name)==-1:
socket=self.node_tree.outputs.new(sockettype, name)
elif is_output==False:
if self.node_tree.nodes['GroupInput'].outputs.find(name)==-1:
socket=self.node_tree.inputs.new(sockettype, name)
return socket

def addNode(self, nodetype, attrs):
Expand Down
22 changes: 14 additions & 8 deletions brick_square_corner_addin.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def createNodetree(self, name) :
self.addNode('ShaderNodeMath', { 'name':'Node31' ,'operation':'GREATER_THAN' })
#Sockets
self.addSocket(False, 'NodeSocketVector', 'Vector')
self.addSocket(False, 'NodeSocketFloatFactor', 'HAS_Vector')
self.addSocket(False, 'NodeSocketFloat', 'HAS_Vector')
self.addSocket(False, 'NodeSocketFloat', 'brick_width')
self.addSocket(False, 'NodeSocketFloat', 'brick_height')
self.addSocket(False, 'NodeSocketFloat', 'border')
Expand Down Expand Up @@ -129,13 +129,19 @@ def getNodetree(self, name):
self.node_tree=bpy.data.node_groups[name]

def addSocket(self, is_output, sockettype, name):
#for now duplicated socket names are not allowed
if is_output==True:
if self.node_tree.nodes['GroupOutput'].inputs.find(name)==-1:
socket=self.node_tree.outputs.new(sockettype, name)
elif is_output==False:
if self.node_tree.nodes['GroupInput'].outputs.find(name)==-1:
socket=self.node_tree.inputs.new(sockettype, name)
if bpy.app.version >= (4, 0, 0):
if is_output==True:
socket = self.node_tree.interface.new_socket(name, in_out='OUTPUT', socket_type=sockettype)
else:
socket = self.node_tree.interface.new_socket(name, in_out='INPUT', socket_type=sockettype)
else:
#for now duplicated socket names are not allowed
if is_output==True:
if self.node_tree.nodes['GroupOutput'].inputs.find(name)==-1:
socket=self.node_tree.outputs.new(sockettype, name)
elif is_output==False:
if self.node_tree.nodes['GroupInput'].outputs.find(name)==-1:
socket=self.node_tree.inputs.new(sockettype, name)
return socket

def addNode(self, nodetype, attrs):
Expand Down
22 changes: 14 additions & 8 deletions uv_map_brick_wall_addin.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def createNodetree(self, name) :
self.addNode('ShaderNodeCombineXYZ', { 'name':'Node67' })
#Sockets
self.addSocket(False, 'NodeSocketVector', 'Vector')
self.addSocket(False, 'NodeSocketFloatFactor', 'HAS_Vector')
self.addSocket(False, 'NodeSocketFloat', 'HAS_Vector')
self.addSocket(False, 'NodeSocketFloat', 'scale')
self.addSocket(False, 'NodeSocketFloat', 'brick_width')
self.addSocket(False, 'NodeSocketFloat', 'brick_height')
Expand Down Expand Up @@ -233,13 +233,19 @@ def getNodetree(self, name):
self.node_tree=bpy.data.node_groups[name]

def addSocket(self, is_output, sockettype, name):
#for now duplicated socket names are not allowed
if is_output==True:
if self.node_tree.nodes['GroupOutput'].inputs.find(name)==-1:
socket=self.node_tree.outputs.new(sockettype, name)
elif is_output==False:
if self.node_tree.nodes['GroupInput'].outputs.find(name)==-1:
socket=self.node_tree.inputs.new(sockettype, name)
if bpy.app.version >= (4, 0, 0):
if is_output==True:
socket = self.node_tree.interface.new_socket(name, in_out='OUTPUT', socket_type=sockettype)
else:
socket = self.node_tree.interface.new_socket(name, in_out='INPUT', socket_type=sockettype)
else:
#for now duplicated socket names are not allowed
if is_output==True:
if self.node_tree.nodes['GroupOutput'].inputs.find(name)==-1:
socket=self.node_tree.outputs.new(sockettype, name)
elif is_output==False:
if self.node_tree.nodes['GroupInput'].outputs.find(name)==-1:
socket=self.node_tree.inputs.new(sockettype, name)
return socket

def addNode(self, nodetype, attrs):
Expand Down
22 changes: 14 additions & 8 deletions uv_map_diamond_addin.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def createNodetree(self, name) :
self.addNode('ShaderNodeMixRGB', { 'name':'Node182' })
#Sockets
self.addSocket(False, 'NodeSocketVector', 'Vector')
self.addSocket(False, 'NodeSocketFloatFactor', 'HAS_Vector')
self.addSocket(False, 'NodeSocketFloat', 'HAS_Vector')
self.addSocket(False, 'NodeSocketFloat', 'scale')
self.addSocket(False, 'NodeSocketFloat', 'diamond_size')
self.addSocket(False, 'NodeSocketFloat', 'brick_width')
Expand Down Expand Up @@ -583,13 +583,19 @@ def getNodetree(self, name):
self.node_tree=bpy.data.node_groups[name]

def addSocket(self, is_output, sockettype, name):
#for now duplicated socket names are not allowed
if is_output==True:
if self.node_tree.nodes['GroupOutput'].inputs.find(name)==-1:
socket=self.node_tree.outputs.new(sockettype, name)
elif is_output==False:
if self.node_tree.nodes['GroupInput'].outputs.find(name)==-1:
socket=self.node_tree.inputs.new(sockettype, name)
if bpy.app.version >= (4, 0, 0):
if is_output==True:
socket = self.node_tree.interface.new_socket(name, in_out='OUTPUT', socket_type=sockettype)
else:
socket = self.node_tree.interface.new_socket(name, in_out='INPUT', socket_type=sockettype)
else:
#for now duplicated socket names are not allowed
if is_output==True:
if self.node_tree.nodes['GroupOutput'].inputs.find(name)==-1:
socket=self.node_tree.outputs.new(sockettype, name)
elif is_output==False:
if self.node_tree.nodes['GroupInput'].outputs.find(name)==-1:
socket=self.node_tree.inputs.new(sockettype, name)
return socket

def addNode(self, nodetype, attrs):
Expand Down
22 changes: 14 additions & 8 deletions uv_map_rotate_addin.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def createNodetree(self, name) :
self.addNode('ShaderNodeMixRGB', { 'name':'Node41' })
#Sockets
self.addSocket(False, 'NodeSocketVector', 'Vector')
self.addSocket(False, 'NodeSocketFloatFactor', 'HAS_Vector')
self.addSocket(False, 'NodeSocketFloat', 'HAS_Vector')
self.addSocket(False, 'NodeSocketFloat', 'brick_width')
self.addSocket(False, 'NodeSocketFloat', 'brick_height')
self.addSocket(False, 'NodeSocketFloat', 'Angle')
Expand Down Expand Up @@ -151,13 +151,19 @@ def getNodetree(self, name):
self.node_tree=bpy.data.node_groups[name]

def addSocket(self, is_output, sockettype, name):
#for now duplicated socket names are not allowed
if is_output==True:
if self.node_tree.nodes['GroupOutput'].inputs.find(name)==-1:
socket=self.node_tree.outputs.new(sockettype, name)
elif is_output==False:
if self.node_tree.nodes['GroupInput'].outputs.find(name)==-1:
socket=self.node_tree.inputs.new(sockettype, name)
if bpy.app.version >= (4, 0, 0):
if is_output==True:
socket = self.node_tree.interface.new_socket(name, in_out='OUTPUT', socket_type=sockettype)
else:
socket = self.node_tree.interface.new_socket(name, in_out='INPUT', socket_type=sockettype)
else:
#for now duplicated socket names are not allowed
if is_output==True:
if self.node_tree.nodes['GroupOutput'].inputs.find(name)==-1:
socket=self.node_tree.outputs.new(sockettype, name)
elif is_output==False:
if self.node_tree.nodes['GroupInput'].outputs.find(name)==-1:
socket=self.node_tree.inputs.new(sockettype, name)
return socket

def addNode(self, nodetype, attrs):
Expand Down
22 changes: 14 additions & 8 deletions uv_map_swirl_addin.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def createNodetree(self, name) :
self.addNode('ShaderNodeCombineXYZ', { 'name':'Node84' })
#Sockets
self.addSocket(False, 'NodeSocketVector', 'Point')
self.addSocket(False, 'NodeSocketFloatFactor', 'HAS_Point')
self.addSocket(False, 'NodeSocketFloat', 'HAS_Point')
self.addSocket(False, 'NodeSocketFloat', 'Scale')
self.addSocket(False, 'NodeSocketVector', 'Center')
self.addSocket(False, 'NodeSocketFloat', 'brickwidth')
Expand Down Expand Up @@ -255,13 +255,19 @@ def getNodetree(self, name):
self.node_tree=bpy.data.node_groups[name]

def addSocket(self, is_output, sockettype, name):
#for now duplicated socket names are not allowed
if is_output==True:
if self.node_tree.nodes['GroupOutput'].inputs.find(name)==-1:
socket=self.node_tree.outputs.new(sockettype, name)
elif is_output==False:
if self.node_tree.nodes['GroupInput'].outputs.find(name)==-1:
socket=self.node_tree.inputs.new(sockettype, name)
if bpy.app.version >= (4, 0, 0):
if is_output==True:
socket = self.node_tree.interface.new_socket(name, in_out='OUTPUT', socket_type=sockettype)
else:
socket = self.node_tree.interface.new_socket(name, in_out='INPUT', socket_type=sockettype)
else:
#for now duplicated socket names are not allowed
if is_output==True:
if self.node_tree.nodes['GroupOutput'].inputs.find(name)==-1:
socket=self.node_tree.outputs.new(sockettype, name)
elif is_output==False:
if self.node_tree.nodes['GroupInput'].outputs.find(name)==-1:
socket=self.node_tree.inputs.new(sockettype, name)
return socket

def addNode(self, nodetype, attrs):
Expand Down
22 changes: 14 additions & 8 deletions uv_map_tile_pattern_1_addin.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def createNodetree(self, name) :
self.addNode('ShaderNodeMixRGB', { 'name':'Node55' })
#Sockets
self.addSocket(False, 'NodeSocketVector', 'Vector')
self.addSocket(False, 'NodeSocketFloatFactor', 'HAS_Vector')
self.addSocket(False, 'NodeSocketFloat', 'HAS_Vector')
self.addSocket(False, 'NodeSocketFloat', 'scale')
self.addSocket(True, 'NodeSocketVector', 'UV')
self.addSocket(True, 'NodeSocketVector', 'cellID')
Expand Down Expand Up @@ -182,13 +182,19 @@ def getNodetree(self, name):
self.node_tree=bpy.data.node_groups[name]

def addSocket(self, is_output, sockettype, name):
#for now duplicated socket names are not allowed
if is_output==True:
if self.node_tree.nodes['GroupOutput'].inputs.find(name)==-1:
socket=self.node_tree.outputs.new(sockettype, name)
elif is_output==False:
if self.node_tree.nodes['GroupInput'].outputs.find(name)==-1:
socket=self.node_tree.inputs.new(sockettype, name)
if bpy.app.version >= (4, 0, 0):
if is_output==True:
socket = self.node_tree.interface.new_socket(name, in_out='OUTPUT', socket_type=sockettype)
else:
socket = self.node_tree.interface.new_socket(name, in_out='INPUT', socket_type=sockettype)
else:
#for now duplicated socket names are not allowed
if is_output==True:
if self.node_tree.nodes['GroupOutput'].inputs.find(name)==-1:
socket=self.node_tree.outputs.new(sockettype, name)
elif is_output==False:
if self.node_tree.nodes['GroupInput'].outputs.find(name)==-1:
socket=self.node_tree.inputs.new(sockettype, name)
return socket

def addNode(self, nodetype, attrs):
Expand Down
Loading

0 comments on commit 7a8606e

Please sign in to comment.