mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
sdf3d rotate, translate, and scale nodes.
This commit is contained in:
parent
32f80f288a
commit
ea9b0a1b2e
@ -1,10 +1,12 @@
|
||||
[gd_resource type="Resource" load_steps=22 format=2]
|
||||
[gd_resource type="Resource" load_steps=31 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/sdf3d/sdf3d_shape_sphere.gd" type="Script" id=2]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf3d/sdf3d_shape_capsule.gd" type="Script" id=2]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf3d/sdf3d_render.gd" type="Script" id=3]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf3d/sdf3d_shape_box.gd" type="Script" id=4]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf3d/sdf3d_tf_scale.gd" type="Script" id=4]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/mm_node_universal_property.gd" type="Script" id=5]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf3d/sdf3d_tf_translate.gd" type="Script" id=6]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf3d/sdf3d_tf_rotate.gd" type="Script" id=7]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf3d/sdf3d_color.gd" type="Script" id=9]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/simple/image.gd" type="Script" id=10]
|
||||
|
||||
@ -77,7 +79,7 @@ out_height_map = SubResource( 28 )
|
||||
out_normal_map = SubResource( 29 )
|
||||
out_color_map = SubResource( 27 )
|
||||
|
||||
[sub_resource type="Resource" id=35]
|
||||
[sub_resource type="Resource" id=42]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 2
|
||||
default_int = 0
|
||||
@ -94,7 +96,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( 35 )
|
||||
input_property = SubResource( 42 )
|
||||
|
||||
[sub_resource type="Resource" id=33]
|
||||
script = ExtResource( 9 )
|
||||
@ -103,7 +105,7 @@ input = SubResource( 32 )
|
||||
output = SubResource( 25 )
|
||||
color = 0.6
|
||||
|
||||
[sub_resource type="Resource" id=31]
|
||||
[sub_resource type="Resource" id=35]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 2
|
||||
default_int = 0
|
||||
@ -112,20 +114,85 @@ default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=34]
|
||||
script = ExtResource( 2 )
|
||||
graph_position = Vector2( 40, 240 )
|
||||
output = SubResource( 31 )
|
||||
radius = 0.43
|
||||
|
||||
[sub_resource type="Resource" id=36]
|
||||
script = ExtResource( 4 )
|
||||
graph_position = Vector2( -200, 0 )
|
||||
script = ExtResource( 2 )
|
||||
graph_position = Vector2( -120, 40 )
|
||||
points = [ 0.0, 1.0, 0.0, 0.0, 0.424679, 0.283912, 0.0, 4.15563, 1.0, 1.0, 0.0, 0.0 ]
|
||||
output = SubResource( 35 )
|
||||
size = Vector3( 0.2, 0.25, 0.25 )
|
||||
radius = 0.12
|
||||
axis = 0
|
||||
length = 0.28
|
||||
radius = 0.22
|
||||
|
||||
[sub_resource type="Resource" id=37]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 2
|
||||
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 )
|
||||
input_property = SubResource( 35 )
|
||||
|
||||
[sub_resource type="Resource" id=38]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 2
|
||||
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=39]
|
||||
script = ExtResource( 6 )
|
||||
graph_position = Vector2( 140, 180 )
|
||||
input = SubResource( 37 )
|
||||
output = SubResource( 38 )
|
||||
translation = Vector3( 0.02, 0.02, 0.09 )
|
||||
|
||||
[sub_resource type="Resource" id=40]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 2
|
||||
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 )
|
||||
input_property = SubResource( 38 )
|
||||
|
||||
[sub_resource type="Resource" id=34]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 2
|
||||
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=41]
|
||||
script = ExtResource( 4 )
|
||||
graph_position = Vector2( 160, 400 )
|
||||
input = SubResource( 40 )
|
||||
output = SubResource( 34 )
|
||||
scale = 1.0
|
||||
|
||||
[sub_resource type="Resource" id=43]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 2
|
||||
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 )
|
||||
input_property = SubResource( 34 )
|
||||
|
||||
[sub_resource type="Resource" id=44]
|
||||
script = ExtResource( 7 )
|
||||
graph_position = Vector2( -100, 380 )
|
||||
input = SubResource( 43 )
|
||||
output = SubResource( 42 )
|
||||
rotation = Vector3( 50, 50, 50 )
|
||||
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
||||
image_size = Vector2( 128, 128 )
|
||||
nodes = [ SubResource( 24 ), SubResource( 30 ), SubResource( 33 ), SubResource( 34 ), SubResource( 36 ) ]
|
||||
nodes = [ SubResource( 24 ), SubResource( 30 ), SubResource( 33 ), SubResource( 36 ), SubResource( 39 ), SubResource( 41 ), SubResource( 44 ) ]
|
||||
|
@ -742,8 +742,26 @@ static func repeat(p : Vector3, r : Vector3, pseed : float, randomness : float)
|
||||
#}
|
||||
|
||||
static func rotate3d(p : Vector3, a : Vector3) -> Vector3:
|
||||
#todo
|
||||
return Vector3()
|
||||
var rv : Vector3 = Vector3()
|
||||
var c : float = 0
|
||||
var s : float = 0
|
||||
c = cos(a.x)
|
||||
s = sin(a.x)
|
||||
rv.x = p.x
|
||||
rv.y = p.y * c + p.z * s
|
||||
rv.z = -p.y * s + p.z * c
|
||||
c = cos(a.y)
|
||||
s = sin(a.y)
|
||||
p.x = rv.x * c + rv.z * s
|
||||
p.y = rv.y
|
||||
p.z = -rv.x * s + rv.z * c
|
||||
c = cos(a.z)
|
||||
s = sin(a.z)
|
||||
rv.x = p.x * c + p.y * s
|
||||
rv.y = -p.x * s + p.y * c
|
||||
rv.z = p.z
|
||||
|
||||
return rv
|
||||
|
||||
#vec3 circle_repeat_transform(vec3 p, float count) {
|
||||
# float r = 6.28/count;float pa = atan(p.x, p.y);
|
||||
|
57
game/addons/mat_maker_gd/nodes/sdf3d/sdf3d_tf_rotate.gd
Normal file
57
game/addons/mat_maker_gd/nodes/sdf3d/sdf3d_tf_rotate.gd
Normal file
@ -0,0 +1,57 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var SDF3D = preload("res://addons/mat_maker_gd/nodes/common/sdf3d.gd")
|
||||
|
||||
export(Resource) var input : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(Vector3) var rotation : Vector3 = Vector3()
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
# input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR2
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !input.is_connected("changed", self, "on_input_changed"):
|
||||
input.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_vector3("get_rotation", "set_rotation", "Rotation", 0.01)
|
||||
|
||||
func get_property_value_sdf3d(uv3 : Vector3) -> Vector2:
|
||||
#$in(rotate3d($uv, -vec3($ax, $ay, $az)*0.01745329251))
|
||||
|
||||
return input.get_value_sdf3d(SDF3D.rotate3d(uv3, -rotation * 0.01745329251))
|
||||
|
||||
#rotation
|
||||
func get_rotation() -> Vector3:
|
||||
return rotation
|
||||
|
||||
func set_rotation(val : Vector3) -> void:
|
||||
rotation = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
56
game/addons/mat_maker_gd/nodes/sdf3d/sdf3d_tf_scale.gd
Normal file
56
game/addons/mat_maker_gd/nodes/sdf3d/sdf3d_tf_scale.gd
Normal file
@ -0,0 +1,56 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var SDF3D = preload("res://addons/mat_maker_gd/nodes/common/sdf3d.gd")
|
||||
|
||||
export(Resource) var input : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(float) var scale : float = 1
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
# input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR2
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !input.is_connected("changed", self, "on_input_changed"):
|
||||
input.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_float("get_scale", "set_scale", "Scale", 0.01)
|
||||
|
||||
func get_property_value_sdf3d(uv3 : Vector3) -> Vector2:
|
||||
#vec2 $(name_uv)_in = $in(($uv)/$s);
|
||||
return input.get_value_sdf3d(uv3 / scale)
|
||||
|
||||
#scale
|
||||
func get_scale() -> float:
|
||||
return scale
|
||||
|
||||
func set_scale(val : float) -> void:
|
||||
scale = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
56
game/addons/mat_maker_gd/nodes/sdf3d/sdf3d_tf_translate.gd
Normal file
56
game/addons/mat_maker_gd/nodes/sdf3d/sdf3d_tf_translate.gd
Normal file
@ -0,0 +1,56 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var SDF3D = preload("res://addons/mat_maker_gd/nodes/common/sdf3d.gd")
|
||||
|
||||
export(Resource) var input : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(Vector3) var translation : Vector3 = Vector3()
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
# input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR2
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !input.is_connected("changed", self, "on_input_changed"):
|
||||
input.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_vector3("get_translation", "set_translation", "Translation", 0.01)
|
||||
|
||||
func get_property_value_sdf3d(uv3 : Vector3) -> Vector2:
|
||||
#$in($uv-vec3($x, $y, $z))
|
||||
return input.get_value_sdf3d(uv3 - translation)
|
||||
|
||||
#translation
|
||||
func get_translation() -> Vector3:
|
||||
return translation
|
||||
|
||||
func set_translation(val : Vector3) -> void:
|
||||
translation = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
Loading…
Reference in New Issue
Block a user