diff --git a/game/addons/mat_maker_gd/editor/mm_graph_node.gd b/game/addons/mat_maker_gd/editor/mm_graph_node.gd index 04f87660..d3340740 100644 --- a/game/addons/mat_maker_gd/editor/mm_graph_node.gd +++ b/game/addons/mat_maker_gd/editor/mm_graph_node.gd @@ -25,6 +25,42 @@ func add_slot_label(input_type : int, output_type : int, getter : String, setter l.text = slot_name add_slot(input_type, output_type, getter, setter, l) + +func add_slot_int(input_type : int, output_type : int, getter : String, setter : String, slot_name : String) -> void: + var bc : VBoxContainer = VBoxContainer.new() + + if slot_name != "": + var l : Label = Label.new() + l.text = slot_name + bc.add_child(l) + + var sb : SpinBox = SpinBox.new() + sb.rounded = true + bc.add_child(sb) + + var slot_idx : int = add_slot(input_type, output_type, getter, setter, bc) + + sb.value = _node.call(getter) + + sb.connect("value_changed", self, "on_int_spinbox_value_changed", [ slot_idx ]) + +func add_slot_float(input_type : int, output_type : int, getter : String, setter : String, slot_name : String) -> void: + var bc : VBoxContainer = VBoxContainer.new() + + if slot_name != "": + var l : Label = Label.new() + l.text = slot_name + bc.add_child(l) + + var sb : SpinBox = SpinBox.new() + bc.add_child(sb) + + var slot_idx : int = add_slot(input_type, output_type, getter, setter, bc) + sb.rounded = false + sb.step = 0 + sb.value = _node.call(getter) + + sb.connect("value_changed", self, "on_float_spinbox_value_changed", [ slot_idx ]) func add_slot(input_type : int, output_type : int, getter : String, setter : String, control : Control) -> int: add_child(control) @@ -88,3 +124,9 @@ func on_node_changed(): #_node.recalculate_image(_material) propagate_node_change() + +func on_int_spinbox_value_changed(val : float, slot_idx) -> void: + _node.call(properties[slot_idx][4], int(val)) + +func on_float_spinbox_value_changed(val : float, slot_idx) -> void: + _node.call(properties[slot_idx][4], val) diff --git a/game/addons/mat_maker_gd/nodes/noise/noise.gd b/game/addons/mat_maker_gd/nodes/noise/noise.gd index ade6a225..b32d6678 100644 --- a/game/addons/mat_maker_gd/nodes/noise/noise.gd +++ b/game/addons/mat_maker_gd/nodes/noise/noise.gd @@ -50,7 +50,7 @@ func gen() -> void: image.unlock() tex.create_from_image(image) - texture = tex + #texture = tex var p_o7136_amplitude = 0.500000000; var p_o7136_frequency = 2.000000000; diff --git a/game/addons/mat_maker_gd/nodes/noise/perlin.gd b/game/addons/mat_maker_gd/nodes/noise/perlin.gd index 4627fd8b..54abd7cd 100644 --- a/game/addons/mat_maker_gd/nodes/noise/perlin.gd +++ b/game/addons/mat_maker_gd/nodes/noise/perlin.gd @@ -15,4 +15,39 @@ func get_value_for(uv : Vector2, slot_idx : int, pseed : int) -> Color: func register_methods(mm_graph_node) -> void: mm_graph_node.add_slot_texture(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_IMAGE, "recalculate_image", "") + mm_graph_node.add_slot_int(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_iterations", "set_iterations", "iterations") + mm_graph_node.add_slot_float(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_persistence", "set_persistence", "persistence") + mm_graph_node.add_slot_float(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_scale_x", "set_scale_x", "scale") + mm_graph_node.add_slot_float(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_scale_y", "set_scale_y", "") +func get_iterations() -> int: + return iterations + +func set_iterations(val : int) -> void: + iterations = val + + emit_changed() + +func get_persistence() -> float: + return persistence + +func set_persistence(val : float) -> void: + persistence = val + + emit_changed() + +func get_scale_x() -> float: + return scale.x + +func set_scale_x(val : float) -> void: + scale.x = val + + emit_changed() + +func get_scale_y() -> float: + return scale.y + +func set_scale_y(val : float) -> void: + scale.y = val + + emit_changed()