mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-18 01:06:47 +01:00
circle_map, kaleidoscope, mirror, repeat, rotate, scale, shear, transform, and translate nodes for mat_maker_gd.
This commit is contained in:
parent
96f2646ccb
commit
f17de5a15d
@ -1892,13 +1892,30 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
# }\t\n
|
||||
#}
|
||||
|
||||
static func transform(uv : Vector2, translate : Vector2, rotate : float, scale : Vector2, repeat : bool) -> Vector2:
|
||||
var rv : Vector2 = Vector2()
|
||||
uv -= translate
|
||||
uv -= Vector2(0.5, 0.5)
|
||||
rv.x = cos(rotate)*uv.x + sin(rotate)*uv.y
|
||||
rv.y = -sin(rotate)*uv.x + cos(rotate)*uv.y
|
||||
rv /= scale
|
||||
rv += Vector2(0.5, 0.5)
|
||||
|
||||
if (repeat):
|
||||
return Commons.fractv2(rv)
|
||||
else:
|
||||
return Commons.clampv2(rv, Vector2(0, 0), Vector2(1, 1))
|
||||
|
||||
#vec2 transform2_clamp(vec2 uv) {\n\t
|
||||
# return clamp(uv, vec2(0.0), vec2(1.0));\n
|
||||
#}
|
||||
|
||||
|
||||
static func transform2_clamp(uv : Vector2) -> Vector2:
|
||||
return Commons.clampv2(uv, Vector2(0, 0), Vector2(1, 1))
|
||||
|
||||
#vec2 transform2(vec2 uv, vec2 translate, float rotate, vec2 scale) {\n \t
|
||||
# vec2 rv;\n\tuv -= translate;\n\t
|
||||
# vec2 rv;\n\t
|
||||
# uv -= translate;\n\t
|
||||
# uv -= vec2(0.5);\n\t
|
||||
# rv.x = cos(rotate)*uv.x + sin(rotate)*uv.y;\n\t
|
||||
# rv.y = -sin(rotate)*uv.x + cos(rotate)*uv.y;\n\t
|
||||
@ -1907,6 +1924,16 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
# return rv;\t\n
|
||||
#}
|
||||
|
||||
static func transform2(uv : Vector2, translate : Vector2, rotate : float, scale : Vector2) -> Vector2:
|
||||
var rv : Vector2 = Vector2()
|
||||
uv -= translate
|
||||
uv -= Vector2(0.5, 0.5)
|
||||
rv.x = cos(rotate)*uv.x + sin(rotate)*uv.y
|
||||
rv.y = -sin(rotate)*uv.x + cos(rotate)*uv.y
|
||||
rv /= scale
|
||||
rv += Vector2(0.5, 0.5)
|
||||
return rv
|
||||
|
||||
#vec2 rotate(vec2 uv, vec2 center, float rotate) {\n \t
|
||||
# vec2 rv;\n\t
|
||||
# uv -= center;\n\t
|
||||
@ -1916,6 +1943,14 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
# return rv;\t\n
|
||||
#}
|
||||
|
||||
static func rotate(uv : Vector2, center : Vector2, rotate : float) -> Vector2:
|
||||
var rv : Vector2 = Vector2()
|
||||
uv -= center
|
||||
rv.x = cos(rotate)*uv.x + sin(rotate)*uv.y
|
||||
rv.y = -sin(rotate)*uv.x + cos(rotate)*uv.y
|
||||
rv += center
|
||||
return rv
|
||||
|
||||
#vec2 scale(vec2 uv, vec2 center, vec2 scale) {\n\t
|
||||
# uv -= center;\n\t
|
||||
# uv /= scale;\n\t
|
||||
@ -1923,10 +1958,26 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
# return uv;\n
|
||||
#}
|
||||
|
||||
static func scale(uv : Vector2, center : Vector2, scale : Vector2) -> Vector2:
|
||||
uv -= center
|
||||
uv /= scale
|
||||
uv += center
|
||||
return uv
|
||||
|
||||
#vec2 uvmirror_h(vec2 uv, float offset) {\n\t
|
||||
# return vec2(max(0, abs(uv.x-0.5)-0.5*offset)+0.5, uv.y);
|
||||
#}
|
||||
|
||||
static func uvmirror_h(uv : Vector2, offset : float) -> Vector2:
|
||||
return Vector2(max(0, abs(uv.x - 0.5) - 0.5 * offset)+0.5, uv.y)
|
||||
|
||||
#vec2 uvmirror_v(vec2 uv, float offset) {\n\t
|
||||
# return vec2(uv.x, max(0, abs(uv.y-0.5)-0.5*offset)+0.5);\n
|
||||
#}
|
||||
|
||||
static func uvmirror_v(uv : Vector2, offset : float) -> Vector2:
|
||||
return Vector2(uv.x, max(0, abs(uv.y - 0.5) - 0.5 * offset) + 0.5)
|
||||
|
||||
#vec2 kal_rotate(vec2 uv, float count, float offset) {\n\t
|
||||
# float pi = 3.14159265359;\n\t
|
||||
# offset *= pi/180.0;\n\t
|
||||
@ -1939,13 +1990,27 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
# return vec2(0.5)+l*vec2(cos(a), sin(a));\n
|
||||
#}
|
||||
|
||||
static func kal_rotate(uv : Vector2, count : float, offset : float) -> Vector2:
|
||||
var pi : float = 3.14159265359
|
||||
offset *= pi / 180.0
|
||||
offset += pi * (1.0/ count + 0.5)
|
||||
uv -= Vector2(0.5, 0.5)
|
||||
|
||||
var l : float = uv.length()
|
||||
var a : float = Commons.modf(atan2(uv.y, uv.x) + offset, 2.0 * pi / count) - offset
|
||||
|
||||
return Vector2(0.5, 0.5) + l * Vector2(cos(a), sin(a))
|
||||
|
||||
#vec2 get_from_tileset(float count, float seed, vec2 uv) {\n\t
|
||||
# return clamp((uv+floor(rand2(vec2(seed))*count))/count, vec2(0.0), vec2(1.0));\n
|
||||
#}
|
||||
|
||||
static func get_from_tileset(count : float, pseed : float, uv : Vector2) -> Vector2:
|
||||
return Commons.clampv2((uv + Commons.floorv2(Commons.rand2(Vector2(pseed, pseed))*count))/count, Vector2(0, 0), Vector2(1, 1))
|
||||
|
||||
#vec2 custom_uv_transform(vec2 uv, vec2 cst_scale, float rnd_rotate, float rnd_scale, vec2 seed) {\n\t
|
||||
# seed = rand2(seed);\n\tuv -= vec2(0.5);\n\t
|
||||
# seed = rand2(seed);\n\t
|
||||
# uv -= vec2(0.5);\n\t
|
||||
# float angle = (seed.x * 2.0 - 1.0) * rnd_rotate;\n\t
|
||||
# float ca = cos(angle);\n\t
|
||||
# float sa = sin(angle);\n\t
|
||||
@ -1957,5 +2022,15 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
# return uv;\n
|
||||
#}
|
||||
|
||||
static func custom_uv_transform(uv : Vector2, cst_scale : Vector2, rnd_rotate : float, rnd_scale : float, pseed : Vector2) -> Vector2:
|
||||
pseed = Commons.rand2(pseed)
|
||||
uv -= Vector2(0.5, 0.5)
|
||||
var angle : float = (pseed.x * 2.0 - 1.0) * rnd_rotate
|
||||
var ca : float = cos(angle)
|
||||
var sa : float = sin(angle)
|
||||
uv = Vector2(ca * uv.x + sa * uv.y, -sa * uv.x + ca * uv.y)
|
||||
uv *= (pseed.y-0.5)*2.0*rnd_scale+1.0
|
||||
uv /= cst_scale
|
||||
uv += Vector2(0.5, 0.5)
|
||||
|
||||
|
||||
return uv
|
||||
|
@ -91,6 +91,31 @@ func get_owner_value(uv : Vector2):
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE:
|
||||
return to_color(owner.get_property_value(uv))
|
||||
|
||||
func get_value_or_zero(uv : Vector2, skip_owner_val : bool = false):
|
||||
if get_value_from_owner && !skip_owner_val:
|
||||
return get_owner_value(uv)
|
||||
|
||||
if !input_property:
|
||||
return get_zero_value()
|
||||
|
||||
if default_type == input_property.default_type:
|
||||
return input_property.get_value(uv)
|
||||
|
||||
if default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_INT:
|
||||
return to_int(input_property.get_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT:
|
||||
return to_float(input_property.get_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2:
|
||||
return to_vector2(input_property.get_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR3:
|
||||
return to_vector3(input_property.get_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR:
|
||||
return to_color(input_property.get_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE:
|
||||
return to_color(input_property.get_value(uv))
|
||||
|
||||
return input_property.get_value(uv)
|
||||
|
||||
func get_value_sdf3d(uv3 : Vector3, skip_owner_val : bool = false) -> Vector2:
|
||||
if get_value_from_owner && !skip_owner_val:
|
||||
return owner.get_property_value_sdf3d(uv3)
|
||||
@ -198,6 +223,22 @@ func set_value(val):
|
||||
|
||||
set_default_value(val)
|
||||
|
||||
func get_zero_value():
|
||||
if default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_INT:
|
||||
return 0
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT:
|
||||
return 0.0
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2:
|
||||
return Vector2()
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR3:
|
||||
return Vector3()
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR:
|
||||
return Color()
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE:
|
||||
return Color()
|
||||
|
||||
return null
|
||||
|
||||
func get_default_value(uv : Vector2 = Vector2()):
|
||||
if default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_INT:
|
||||
return default_int
|
||||
|
70
game/addons/mat_maker_gd/nodes/transform/circle_map.gd
Normal file
70
game/addons/mat_maker_gd/nodes/transform/circle_map.gd
Normal file
@ -0,0 +1,70 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Transforms = preload("res://addons/mat_maker_gd/nodes/common/transforms.gd")
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
|
||||
export(float) var radius : float = 1
|
||||
export(int) var repeat : int = 1
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01)
|
||||
mm_graph_node.add_slot_int("get_repeat", "set_repeat", "Repeat")
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
#$in(vec2(fract($repeat*atan($uv.y-0.5, $uv.x-0.5)*0.15915494309), min(0.99999, 2.0/$radius*length($uv-vec2(0.5)))))",
|
||||
|
||||
var nuv : Vector2 = Vector2(Commons.fractf(repeat*atan2(uv.y - 0.5, uv.x - 0.5) * 0.15915494309), min(0.99999, 2.0 / radius * (uv - Vector2(0.5, 0.5)).length()))
|
||||
|
||||
return input.get_value(nuv)
|
||||
|
||||
#radius
|
||||
func get_radius() -> float:
|
||||
return radius
|
||||
|
||||
func set_radius(val : float) -> void:
|
||||
radius = val
|
||||
|
||||
if radius == 0:
|
||||
radius = 0.000000001
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#repeat
|
||||
func get_repeat() -> int:
|
||||
return repeat
|
||||
|
||||
func set_repeat(val : int) -> void:
|
||||
repeat = val
|
||||
|
||||
set_dirty(true)
|
63
game/addons/mat_maker_gd/nodes/transform/kaleidoscope.gd
Normal file
63
game/addons/mat_maker_gd/nodes/transform/kaleidoscope.gd
Normal file
@ -0,0 +1,63 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Transforms = preload("res://addons/mat_maker_gd/nodes/common/transforms.gd")
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(int) var count : int = 5
|
||||
export(float) var offset : float = 0
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_int("get_count", "set_count", "Count")
|
||||
mm_graph_node.add_slot_float("get_offset", "set_offset", "Offset", 0.5)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
#$i(kal_rotate($uv, $count, $offset))
|
||||
return input.get_value(Transforms.kal_rotate(uv, count, offset))
|
||||
|
||||
#count
|
||||
func get_count() -> int:
|
||||
return count
|
||||
|
||||
func set_count(val : int) -> void:
|
||||
count = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#offset
|
||||
func get_offset() -> float:
|
||||
return offset
|
||||
|
||||
func set_offset(val : float) -> void:
|
||||
offset = val
|
||||
|
||||
set_dirty(true)
|
69
game/addons/mat_maker_gd/nodes/transform/mirror.gd
Normal file
69
game/addons/mat_maker_gd/nodes/transform/mirror.gd
Normal file
@ -0,0 +1,69 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Transforms = preload("res://addons/mat_maker_gd/nodes/common/transforms.gd")
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(int, "Horizontal,Vertical") var direction : int = 0
|
||||
export(float) var offset : float = 0
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_enum("get_direction", "set_direction", "Direction", [ "Horizontal", "Vertical" ])
|
||||
mm_graph_node.add_slot_float("get_offset", "set_offset", "offset", 0.01)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
#$i(uvmirror_$direction($uv, $offset))
|
||||
|
||||
if direction == 0:
|
||||
return input.get_value(Transforms.uvmirror_h(uv, offset))
|
||||
elif direction == 1:
|
||||
return input.get_value(Transforms.uvmirror_v(uv, offset))
|
||||
|
||||
return Color(0, 0, 0, 1)
|
||||
|
||||
#direction
|
||||
func get_direction() -> int:
|
||||
return direction
|
||||
|
||||
func set_direction(val : int) -> void:
|
||||
direction = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#offset
|
||||
func get_offset() -> float:
|
||||
return offset
|
||||
|
||||
func set_offset(val : float) -> void:
|
||||
offset = val
|
||||
|
||||
set_dirty(true)
|
27
game/addons/mat_maker_gd/nodes/transform/repeat.gd
Normal file
27
game/addons/mat_maker_gd/nodes/transform/repeat.gd
Normal file
@ -0,0 +1,27 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
export(Resource) var input : Resource
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Apply >>>"
|
||||
#input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_COLOR
|
||||
input.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.get_value_from_owner = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(input)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
|
||||
func get_property_value(uv : Vector2):
|
||||
return input.get_value(Commons.fractv2(uv), true)
|
63
game/addons/mat_maker_gd/nodes/transform/rotate.gd
Normal file
63
game/addons/mat_maker_gd/nodes/transform/rotate.gd
Normal file
@ -0,0 +1,63 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Transforms = preload("res://addons/mat_maker_gd/nodes/common/transforms.gd")
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(Vector2) var center : Vector2 = Vector2()
|
||||
export(float) var rotate : float = 0
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_vector2("get_center", "set_center", "Center", 0.01)
|
||||
mm_graph_node.add_slot_float("get_rotate", "set_rotate", "Rotate", 0.1)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
#$i(rotate($uv, vec2(0.5+$cx, 0.5+$cy), $rotate*0.01745329251))
|
||||
return input.get_value(Transforms.rotate(uv, center + Vector2(0.5, 0.5), rotate*0.01745329251))
|
||||
|
||||
#center
|
||||
func get_center() -> Vector2:
|
||||
return center
|
||||
|
||||
func set_center(val : Vector2) -> void:
|
||||
center = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#rotate
|
||||
func get_rotate() -> float:
|
||||
return rotate
|
||||
|
||||
func set_rotate(val : float) -> void:
|
||||
rotate = val
|
||||
|
||||
set_dirty(true)
|
63
game/addons/mat_maker_gd/nodes/transform/scale.gd
Normal file
63
game/addons/mat_maker_gd/nodes/transform/scale.gd
Normal file
@ -0,0 +1,63 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Transforms = preload("res://addons/mat_maker_gd/nodes/common/transforms.gd")
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(Vector2) var center : Vector2 = Vector2()
|
||||
export(Vector2) var scale : Vector2 = Vector2(1, 1)
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_vector2("get_center", "set_center", "Center", 0.01)
|
||||
mm_graph_node.add_slot_vector2("get_scale", "set_scale", "Scale", 0.01)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
#$i(scale($uv, vec2(0.5+$cx, 0.5+$cy), vec2($scale_x, $scale_y)))
|
||||
return input.get_value(Transforms.scale(uv, center + Vector2(0.5, 0.5), scale))
|
||||
|
||||
#center
|
||||
func get_center() -> Vector2:
|
||||
return center
|
||||
|
||||
func set_center(val : Vector2) -> void:
|
||||
center = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#scale
|
||||
func get_scale() -> Vector2:
|
||||
return scale
|
||||
|
||||
func set_scale(val : Vector2) -> void:
|
||||
scale = val
|
||||
|
||||
set_dirty(true)
|
79
game/addons/mat_maker_gd/nodes/transform/shear.gd
Normal file
79
game/addons/mat_maker_gd/nodes/transform/shear.gd
Normal file
@ -0,0 +1,79 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(int, "Horizontal,Vertical") var direction : int = 0
|
||||
export(float) var amount : float = 1
|
||||
export(float) var center : float = 0
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_enum("get_direction", "set_direction", "Direction", [ "Horizontal", "Vertical" ])
|
||||
mm_graph_node.add_slot_float("get_amount", "set_amount", "Amount", 0.01)
|
||||
mm_graph_node.add_slot_float("get_center", "set_center", "Center", 0.01)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
#$in($uv+$amount*($uv.yx-vec2($center))*vec2($direction))
|
||||
|
||||
if direction == 0:
|
||||
return input.get_value(uv + amount * (Vector2(uv.y, uv.x) - Vector2(center, center)) * Vector2(1, 0))
|
||||
elif direction == 1:
|
||||
return input.get_value(uv + amount * (Vector2(uv.y, uv.x) - Vector2(center, center)) * Vector2(0, 1))
|
||||
|
||||
return Color(0, 0, 0, 1)
|
||||
|
||||
#direction
|
||||
func get_direction() -> int:
|
||||
return direction
|
||||
|
||||
func set_direction(val : int) -> void:
|
||||
direction = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#amount
|
||||
func get_amount() -> float:
|
||||
return amount
|
||||
|
||||
func set_amount(val : float) -> void:
|
||||
amount = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#center
|
||||
func get_center() -> float:
|
||||
return center
|
||||
|
||||
func set_center(val : float) -> void:
|
||||
center = val
|
||||
|
||||
set_dirty(true)
|
132
game/addons/mat_maker_gd/nodes/transform/transform.gd
Normal file
132
game/addons/mat_maker_gd/nodes/transform/transform.gd
Normal file
@ -0,0 +1,132 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Transforms = preload("res://addons/mat_maker_gd/nodes/common/transforms.gd")
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
|
||||
export(Resource) var translate_x : Resource
|
||||
export(Resource) var translate_y : Resource
|
||||
export(Resource) var rotate : Resource
|
||||
export(Resource) var scale_x : Resource
|
||||
export(Resource) var scale_y : Resource
|
||||
export(int, "Clamp,Repeat,Extend") var mode : int = 0
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
if !translate_x:
|
||||
translate_x = MMNodeUniversalProperty.new()
|
||||
translate_x.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
translate_x.set_default_value(0)
|
||||
translate_x.value_step = 0.01
|
||||
|
||||
translate_x.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
translate_x.slot_name = "Translate X"
|
||||
|
||||
if !translate_y:
|
||||
translate_y = MMNodeUniversalProperty.new()
|
||||
translate_y.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
translate_y.set_default_value(0)
|
||||
translate_y.value_step = 0.01
|
||||
|
||||
translate_y.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
translate_y.slot_name = "Translate Y"
|
||||
|
||||
if !rotate:
|
||||
rotate = MMNodeUniversalProperty.new()
|
||||
rotate.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
rotate.set_default_value(0)
|
||||
rotate.value_step = 0.01
|
||||
|
||||
rotate.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
rotate.slot_name = "Rotate"
|
||||
|
||||
if !scale_x:
|
||||
scale_x = MMNodeUniversalProperty.new()
|
||||
scale_x.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
scale_x.set_default_value(1)
|
||||
scale_x.value_step = 0.01
|
||||
|
||||
scale_x.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
scale_x.slot_name = "Scale X"
|
||||
|
||||
if !scale_y:
|
||||
scale_y = MMNodeUniversalProperty.new()
|
||||
scale_y.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
scale_y.set_default_value(1)
|
||||
scale_y.value_step = 0.01
|
||||
|
||||
scale_y.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
scale_y.slot_name = "Scale Y"
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
register_input_property(translate_x)
|
||||
register_input_property(translate_y)
|
||||
register_input_property(rotate)
|
||||
register_input_property(scale_x)
|
||||
register_input_property(scale_y)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
|
||||
mm_graph_node.add_slot_float_universal(translate_x)
|
||||
mm_graph_node.add_slot_float_universal(translate_y)
|
||||
mm_graph_node.add_slot_float_universal(rotate)
|
||||
mm_graph_node.add_slot_float_universal(scale_x)
|
||||
mm_graph_node.add_slot_float_universal(scale_y)
|
||||
|
||||
mm_graph_node.add_slot_enum("get_mode", "set_mode", "Mode", [ "Clamp", "Repeat", "Extend" ])
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
#$i($mode(transform2($uv, vec2($translate_x*(2.0*$tx($uv)-1.0), $translate_y*(2.0*$ty($uv)-1.0)), $rotate*0.01745329251*(2.0*$r($uv)-1.0), vec2($scale_x*(2.0*$sx($uv)-1.0), $scale_y*(2.0*$sy($uv)-1.0)))))",
|
||||
|
||||
#Mode:
|
||||
#Clamp -> transform2_clamp
|
||||
#Repeat -> fract
|
||||
#Extend -> ""
|
||||
|
||||
var tr : Vector2 = Vector2(translate_x.get_default_value() * (2.0 * translate_x.get_value_or_zero(uv) - 1.0), translate_y.get_default_value() *(2.0 * translate_y.get_value_or_zero(uv) - 1.0))
|
||||
var rot : float = rotate.get_default_value() * 0.01745329251*(2.0 * rotate.get_value_or_zero(uv) - 1.0)
|
||||
var sc : Vector2 = Vector2(scale_x.get_default_value() *(2.0 * scale_x.get_value_or_zero(uv) - 1.0), scale_y.get_default_value() *(2.0 * scale_y.get_value_or_zero(uv) - 1.0))
|
||||
|
||||
var nuv : Vector2 = Transforms.transform2(uv, tr, rot, sc)
|
||||
|
||||
if mode == 0:
|
||||
nuv = Transforms.transform2_clamp(nuv)
|
||||
elif mode == 1:
|
||||
nuv = Commons.fractv2(nuv)
|
||||
|
||||
return input.get_value(nuv)
|
||||
|
||||
#mode
|
||||
func get_mode() -> int:
|
||||
return mode
|
||||
|
||||
func set_mode(val : int) -> void:
|
||||
mode = val
|
||||
|
||||
set_dirty(true)
|
51
game/addons/mat_maker_gd/nodes/transform/translate.gd
Normal file
51
game/addons/mat_maker_gd/nodes/transform/translate.gd
Normal file
@ -0,0 +1,51 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(Vector2) var translation : Vector2 = Vector2()
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_vector2("get_translation", "set_translation", "Translation", 0.01)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
#$i($uv-vec2($translate_x, $translate_y))
|
||||
return input.get_value(uv - translation)
|
||||
|
||||
#translation
|
||||
func get_translation() -> Vector2:
|
||||
return translation
|
||||
|
||||
func set_translation(val : Vector2) -> void:
|
||||
translation = val
|
||||
|
||||
set_dirty(true)
|
Loading…
Reference in New Issue
Block a user