From 82f83ca482e1e1ef0c6ce99dd1dc0ac2950a3093 Mon Sep 17 00:00:00 2001 From: RodZill4 Date: Wed, 11 Sep 2019 07:53:06 +0200 Subject: [PATCH] More fixes and cleanup --- addons/material_maker/engine/gen_buffer.gd | 3 + addons/material_maker/engine/gen_shader.gd | 9 +++ addons/material_maker/graph_edit.gd | 4 +- addons/material_maker/nodes/generic.gd | 17 ++--- addons/material_maker/nodes/warp/warp.tscn | 75 +------------------ .../material_maker/widgets/gradient_editor.gd | 1 - 6 files changed, 26 insertions(+), 83 deletions(-) diff --git a/addons/material_maker/engine/gen_buffer.gd b/addons/material_maker/engine/gen_buffer.gd index 79f498a..b7f0f90 100644 --- a/addons/material_maker/engine/gen_buffer.gd +++ b/addons/material_maker/engine/gen_buffer.gd @@ -22,6 +22,9 @@ func get_parameter_defs(): func get_input_defs(): return [ { name="in", type="rgba" } ] + +func get_output_defs(): + return [ { type="rgba" } ] func _get_shader_code(uv : String, output_index : int, context : MMGenContext): var source = get_source(0) diff --git a/addons/material_maker/engine/gen_shader.gd b/addons/material_maker/engine/gen_shader.gd index 82136fa..2e98e53 100644 --- a/addons/material_maker/engine/gen_shader.gd +++ b/addons/material_maker/engine/gen_shader.gd @@ -33,6 +33,15 @@ func get_output_defs(): func set_shader_model(data: Dictionary): shader_model = data init_parameters() + if shader_model.has("outputs"): + for i in range(shader_model.outputs.size()): + var output = shader_model.outputs[i] + if output.has("rgba"): + shader_model.outputs[i].type = "rgba" + elif output.has("rgb"): + shader_model.outputs[i].type = "rgb" + else: + shader_model.outputs[i].type = "f" func find_keyword_call(string, keyword): var search_string = "$%s(" % keyword diff --git a/addons/material_maker/graph_edit.gd b/addons/material_maker/graph_edit.gd index 880ab96..c29dd6e 100644 --- a/addons/material_maker/graph_edit.gd +++ b/addons/material_maker/graph_edit.gd @@ -64,7 +64,9 @@ func remove_node(node): # Global operations on graph func update_tab_title(): + print("update_tab_title") if !get_parent().has_method("set_tab_title"): + print("no set_tab_title method") return var title = "[unnamed]" if save_path != null: @@ -115,7 +117,7 @@ func new_material(): if generator != null: add_child(generator) update_graph(generator.get_children(), generator.connections) - set_save_path(filename) + set_save_path(null) set_need_save(false) center_view() diff --git a/addons/material_maker/nodes/generic.gd b/addons/material_maker/nodes/generic.gd index 1c39db4..457c8ff 100644 --- a/addons/material_maker/nodes/generic.gd +++ b/addons/material_maker/nodes/generic.gd @@ -180,17 +180,14 @@ func update_node(): var outputs = generator.get_output_defs() for i in range(outputs.size()): var output = outputs[i] - var enable_right = false + var enable_right = true var color_right = Color(0.5, 0.5, 0.5) - if typeof(output) == TYPE_DICTIONARY: - if output.has("rgb"): - enable_right = true - color_right = Color(0.5, 0.5, 1.0) - elif output.has("rgba"): - enable_right = true - color_right = Color(0.0, 0.5, 0.0, 0.5) - elif output.has("f"): - enable_right = true + assert(typeof(output) == TYPE_DICTIONARY) + assert(output.has("type")) + enable_right = true + match output.type: + "rgb": color_right = Color(0.5, 0.5, 1.0) + "rgba": color_right = Color(0.0, 0.5, 0.0, 0.5) set_slot(i, is_slot_enabled_left(i), get_slot_type_left(i), get_slot_color_left(i), enable_right, 0, color_right) if i >= get_child_count(): var control = Control.new() diff --git a/addons/material_maker/nodes/warp/warp.tscn b/addons/material_maker/nodes/warp/warp.tscn index 00decbf..9c01860 100644 --- a/addons/material_maker/nodes/warp/warp.tscn +++ b/addons/material_maker/nodes/warp/warp.tscn @@ -4,31 +4,15 @@ [sub_resource type="Theme" id=1] - -[node name="Warp" type="GraphNode" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="Warp" type="GraphNode"] margin_left = 1.0 margin_top = 1.0 margin_right = 91.0 margin_bottom = 84.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false mouse_filter = 1 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 theme = SubResource( 1 ) title = "Warp" -offset = Vector2( 0, 0 ) show_close = true -resizable = false -selected = false -comment = false -overlay = 0 slot/0/left_enabled = true slot/0/left_type = 0 slot/0/left_color = Color( 0.5, 0.5, 1, 1 ) @@ -48,78 +32,27 @@ slot/2/right_enabled = false slot/2/right_type = 0 slot/2/right_color = Color( 1, 1, 1, 1 ) script = ExtResource( 1 ) -_sections_unfolded = [ "Theme", "slot", "slot/1" ] -[node name="Label1" type="Label" parent="." index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="Label1" type="Label" parent="."] margin_left = 16.0 margin_top = 24.0 margin_right = 90.0 margin_bottom = 38.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 text = "Source" -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -[node name="Label2" type="Label" parent="." index="1"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="Label2" type="Label" parent="."] margin_left = 16.0 margin_top = 38.0 margin_right = 90.0 margin_bottom = 52.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 text = "Displace" -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -[node name="amount" type="SpinBox" parent="." index="2"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 +[node name="amount" type="SpinBox" parent="."] margin_left = 16.0 margin_top = 53.0 margin_right = 90.0 margin_bottom = 77.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -min_value = 0.0 max_value = 1.0 step = 0.05 -page = 0.0 value = 0.5 -exp_edit = false -rounded = false -editable = true -prefix = "" -suffix = "" -_sections_unfolded = [ "Caret", "Placeholder" ] - [connection signal="close_request" from="." to="." method="queue_free"] - - diff --git a/addons/material_maker/widgets/gradient_editor.gd b/addons/material_maker/widgets/gradient_editor.gd index 9c209fc..e79453a 100644 --- a/addons/material_maker/widgets/gradient_editor.gd +++ b/addons/material_maker/widgets/gradient_editor.gd @@ -56,7 +56,6 @@ func set_value(v): remove_child(c) c.free() for p in value.points: - print(p) add_cursor(p.v*(rect_size.x-GradientCursor.WIDTH), p.c) update_shader()