mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
sd_annular_shape node.
This commit is contained in:
parent
d2dd31ae72
commit
d570d8aea3
@ -1,4 +1,4 @@
|
||||
[gd_resource type="Resource" load_steps=89 format=2]
|
||||
[gd_resource type="Resource" load_steps=92 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/mm_material.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/noise/noise.gd" type="Script" id=2]
|
||||
@ -23,6 +23,7 @@
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf2d/sd_op_bool.gd" type="Script" id=21]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf2d/sd_op_smooth_bool.gd" type="Script" id=22]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf2d/sd_op_rounded_shape.gd" type="Script" id=23]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf2d/sd_op_annular_shape.gd" type="Script" id=24]
|
||||
|
||||
[sub_resource type="Resource" id=3]
|
||||
script = ExtResource( 5 )
|
||||
@ -60,7 +61,7 @@ sides = 11
|
||||
radius = SubResource( 4 )
|
||||
edge = SubResource( 3 )
|
||||
|
||||
[sub_resource type="Resource" id=83]
|
||||
[sub_resource type="Resource" id=86]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
@ -72,7 +73,7 @@ default_color = Color( 0, 0, 0, 1 )
|
||||
[sub_resource type="Resource" id=6]
|
||||
script = ExtResource( 6 )
|
||||
graph_position = Vector2( 300, -400 )
|
||||
image = SubResource( 83 )
|
||||
image = SubResource( 86 )
|
||||
postfix = "-test"
|
||||
|
||||
[sub_resource type="Resource" id=9]
|
||||
@ -354,7 +355,7 @@ default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=84]
|
||||
[sub_resource type="Resource" id=87]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
@ -372,7 +373,7 @@ default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 84 )
|
||||
input_property = SubResource( 87 )
|
||||
|
||||
[sub_resource type="Resource" id=49]
|
||||
script = ExtResource( 13 )
|
||||
@ -584,13 +585,29 @@ output = SubResource( 79 )
|
||||
operation = 1
|
||||
smoothness = 0.04
|
||||
|
||||
[sub_resource type="Resource" id=84]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=85]
|
||||
script = ExtResource( 23 )
|
||||
graph_position = Vector2( 1460, -500 )
|
||||
output = SubResource( 84 )
|
||||
radius = 0.19
|
||||
|
||||
[sub_resource type="Resource" id=88]
|
||||
script = ExtResource( 24 )
|
||||
graph_position = Vector2( 740, -620 )
|
||||
output = SubResource( 87 )
|
||||
width = 0.02
|
||||
ripples = 3
|
||||
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
||||
image_size = Vector2( 128, 128 )
|
||||
nodes = [ SubResource( 5 ), SubResource( 6 ), SubResource( 12 ), SubResource( 15 ), SubResource( 18 ), SubResource( 21 ), SubResource( 24 ), SubResource( 27 ), SubResource( 39 ), SubResource( 42 ), SubResource( 45 ), SubResource( 49 ), SubResource( 54 ), SubResource( 58 ), SubResource( 60 ), SubResource( 63 ), SubResource( 66 ), SubResource( 69 ), SubResource( 71 ), SubResource( 73 ), SubResource( 78 ), SubResource( 82 ), SubResource( 85 ) ]
|
||||
nodes = [ SubResource( 5 ), SubResource( 6 ), SubResource( 12 ), SubResource( 15 ), SubResource( 18 ), SubResource( 21 ), SubResource( 24 ), SubResource( 27 ), SubResource( 39 ), SubResource( 42 ), SubResource( 45 ), SubResource( 49 ), SubResource( 54 ), SubResource( 58 ), SubResource( 60 ), SubResource( 63 ), SubResource( 66 ), SubResource( 69 ), SubResource( 71 ), SubResource( 73 ), SubResource( 78 ), SubResource( 82 ), SubResource( 85 ), SubResource( 88 ) ]
|
||||
|
@ -926,50 +926,15 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
#sdannularshape.mmg
|
||||
#Creates an annular shape from a shape described as a signed distance function
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "label": "",
|
||||
# "longdesc": "The input shape, defined as a signed distance function",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "sdf2d"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The generated layered shape",
|
||||
# "sdf2d": "sdRipples($in($uv), $r, int($ripples))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "sdf2d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Width",
|
||||
# "longdesc": "The width of each generated ripple",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "r",
|
||||
# "shortdesc": "Width",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Ripples",
|
||||
# "longdesc": "The number of generated ripples",
|
||||
# "max": 16,
|
||||
# "min": 0,
|
||||
# "name": "ripples",
|
||||
# "shortdesc": "Ripples",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
#Output
|
||||
|
||||
#Output float (color) - Shows the shape as a greyscale image
|
||||
#sdRipples($in($uv), $r, int($ripples))
|
||||
|
||||
#Input:
|
||||
#Input (sdf - shape), default: 0 - sdf2d - universal input
|
||||
#width, float, min 0, max 1, step 0.01, default 0
|
||||
#rippples, int, min 1, max 16, default 1
|
||||
|
||||
#----------------------
|
||||
#sd_mask_to_sdf.mmg
|
||||
@ -2482,14 +2447,20 @@ static func sdSmoothIntersection(d1 : float, d2 : float, k : float) -> float:
|
||||
return 0.0
|
||||
|
||||
|
||||
#float sdRipples(float d, float w, int r) {\n\t
|
||||
# for (int i = 0; i < r; ++i) {\n\t\t
|
||||
# d = abs(d)-w;\n\t
|
||||
# }\n\t
|
||||
#float sdRipples(float d, float w, int r) {\n
|
||||
# for (int i = 0; i < r; ++i) {
|
||||
# d = abs(d)-w;
|
||||
# }
|
||||
#
|
||||
# return d;\n
|
||||
# return d;
|
||||
#}
|
||||
|
||||
static func sdRipples(d : float, w : float, r : int) -> float:
|
||||
for i in range(r):
|
||||
d = abs(d)-w;
|
||||
|
||||
return d
|
||||
|
||||
#$polygon = { p1(vec2), p2(vec2), p3(vec2) ... }
|
||||
#float sdPolygon_$(name)(vec2 p) {
|
||||
# vec2 v[] = $polygon;
|
||||
|
53
game/addons/mat_maker_gd/nodes/sdf2d/sd_op_annular_shape.gd
Normal file
53
game/addons/mat_maker_gd/nodes/sdf2d/sd_op_annular_shape.gd
Normal file
@ -0,0 +1,53 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var SDF2D = preload("res://addons/mat_maker_gd/nodes/common/sdf2d.gd")
|
||||
|
||||
export(Resource) var output : Resource
|
||||
export(float) var width : float = 0.1
|
||||
export(int) var ripples : int = 1
|
||||
|
||||
func _init_properties():
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
output.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
#output.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Apply >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(output)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_float("get_width", "set_width", "Width", 0.01)
|
||||
mm_graph_node.add_slot_int("get_ripples", "set_ripples", "Ripples")
|
||||
|
||||
func get_property_value(uv : Vector2):
|
||||
var val : float = output.get_value(uv, true)
|
||||
|
||||
return SDF2D.sdRipples(val, width, ripples)
|
||||
|
||||
#width
|
||||
func get_width() -> float:
|
||||
return width
|
||||
|
||||
func set_width(val : float) -> void:
|
||||
width = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
#ripples
|
||||
func get_ripples() -> int:
|
||||
return ripples
|
||||
|
||||
func set_ripples(val : int) -> void:
|
||||
ripples = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
Loading…
Reference in New Issue
Block a user