From 7f4cc79a4777f819327e3734ff7c39b01d6ba3e2 Mon Sep 17 00:00:00 2001 From: Rodolphe Suescun Date: Sun, 4 Nov 2018 15:43:02 +0100 Subject: [PATCH] Fixed a few problems reported by Godot 3.1a2 --- addons/material_maker/examples/clump_of_grass.ptex | 1 + addons/material_maker/examples/mandelbrot.ptex | 2 +- addons/material_maker/graph_edit.gd | 2 +- addons/material_maker/main_window.tscn | 4 ---- addons/material_maker/node_base.gd | 3 +++ addons/material_maker/nodes/blend/blend.gd | 2 +- addons/material_maker/nodes/colorize/colorize.gd | 2 +- addons/material_maker/nodes/combine/combine.gd | 2 +- addons/material_maker/nodes/comment/comment.gd | 2 +- addons/material_maker/nodes/export/export.gd | 2 +- addons/material_maker/nodes/material/material.gd | 2 +- addons/material_maker/nodes/normal_map/normal_map.gd | 2 +- addons/material_maker/nodes/remote/remote.gd | 2 +- addons/material_maker/nodes/transform/transform.gd | 2 +- addons/material_maker/nodes/warp/warp.gd | 2 +- addons/material_maker/widgets/gradient_editor.gd | 4 ++-- .../widgets/linked_widgets/linked_control_base.gd | 3 +++ addons/material_maker/widgets/tabs.gd | 4 ++-- 18 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 addons/material_maker/examples/clump_of_grass.ptex diff --git a/addons/material_maker/examples/clump_of_grass.ptex b/addons/material_maker/examples/clump_of_grass.ptex new file mode 100644 index 0000000..2ecb48e --- /dev/null +++ b/addons/material_maker/examples/clump_of_grass.ptex @@ -0,0 +1 @@ +{"connections":[{"from":"colorize_0","from_port":0,"to":"Material","to_port":0},{"from":"perlin_0","from_port":0,"to":"blend_0","to_port":1},{"from":"pattern_0","from_port":0,"to":"blend_0","to_port":0},{"from":"blend_0","from_port":0,"to":"transform_0","to_port":0},{"from":"transform_0","from_port":0,"to":"colorize_0","to_port":0},{"from":"colorize_1","from_port":0,"to":"transform_0","to_port":4},{"from":"pattern_1","from_port":0,"to":"colorize_1","to_port":0},{"from":"transform_0","from_port":0,"to":"normal_map_0","to_port":0},{"from":"normal_map_0","from_port":0,"to":"Material","to_port":4}],"nodes":[{"name":"perlin_0","node_position":{"x":-254,"y":101},"parameters":{"iterations":4,"persistence":1,"scale_x":32,"scale_y":4},"type":"perlin"},{"name":"pattern_0","node_position":{"x":-272,"y":-14},"parameters":{"mix":0,"x_scale":1,"x_wave":0,"y_scale":1,"y_wave":3},"type":"pattern"},{"name":"blend_0","node_position":{"x":-4,"y":18},"parameters":{"amount":1,"blend_type":2},"type":"blend"},{"name":"pattern_1","node_position":{"x":-295,"y":245},"parameters":{"mix":0,"x_scale":4,"x_wave":4,"y_scale":1,"y_wave":3},"type":"pattern"},{"name":"colorize_1","node_position":{"x":-8,"y":207},"parameters":{"gradient":{"points":[{"a":1,"b":1,"g":1,"pos":0,"r":1},{"a":1,"b":0.765625,"g":0.765625,"pos":1,"r":0.765625}],"type":"Gradient"}},"type":"colorize"},{"name":"transform_0","node_position":{"x":206,"y":16},"parameters":{"repeat":false,"rotate":0,"scale_x":1.6,"scale_y":1,"translate_x":0,"translate_y":0},"type":"transform"},{"name":"colorize_0","node_position":{"x":435,"y":12},"parameters":{"gradient":{"points":[{"a":0,"b":0,"g":0.5,"pos":0.081818,"r":0.125},{"a":1,"b":0,"g":0.5,"pos":0.145455,"r":0.125},{"a":1,"b":0,"g":0.203125,"pos":0.436364,"r":0.050781},{"a":1,"b":0,"g":0.362165,"pos":0.727273,"r":0.090541},{"a":1,"b":0,"g":0.203125,"pos":1,"r":0.050781}],"type":"Gradient"}},"type":"colorize"},{"name":"normal_map_0","node_position":{"x":459.70459,"y":136},"parameters":{"amount":0.5,"size":2},"type":"normal_map"},{"name":"Material","node_position":{"x":790,"y":-6},"parameters":{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":0,"normal_scale":1,"resolution":1,"roughness":1},"type":"material"}]} \ No newline at end of file diff --git a/addons/material_maker/examples/mandelbrot.ptex b/addons/material_maker/examples/mandelbrot.ptex index 68dd796..73a2143 100644 --- a/addons/material_maker/examples/mandelbrot.ptex +++ b/addons/material_maker/examples/mandelbrot.ptex @@ -1 +1 @@ -{"connections":[{"from":"colorize_0","from_port":0,"to":"Material","to_port":0},{"from":"custom_0","from_port":0,"to":"colorize_0","to_port":0}],"nodes":[{"name":"Material","node_position":{"x":200,"y":0},"parameters":{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"normal_scale":1,"resolution":1,"roughness":1},"type":"material"},{"name":"colorize_0","node_position":{"x":1.25,"y":77.75},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0,"r":1},{"a":1,"b":0,"g":0.96875,"pos":0.2,"r":1},{"a":1,"b":0.0625,"g":1,"pos":0.4,"r":0},{"a":1,"b":1,"g":1,"pos":0.618182,"r":0},{"a":1,"b":0.965909,"g":0,"pos":0.818182,"r":0},{"a":1,"b":1,"g":0,"pos":1,"r":0.9375}],"type":"Gradient"}},"type":"colorize"},{"model_data":{"global":"float mandelbrot(vec2 uv) {\n float di = 1.0;\n vec2 z = vec2(0.0);\n float m2 = 0.0;\n vec2 dz = vec2(0.0);\n for( int i=0; i<200; i++ )\n {\n if (m2>1024.0 ) {\n\t\t\tdi=0.0;\n\t\t\tbreak;\n\t\t}\n\n\t\t// Z' -> 2·Z·Z' + 1\n dz = 2.0*vec2(z.x*dz.x-z.y*dz.y, z.x*dz.y + z.y*dz.x) + vec2(1.0,0.0);\n\t\t\t\n // Z -> Z² + c\t\t\t\n z = vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y ) + uv;\n\t\t\t\n m2 = dot(z,z);\n }\n\n // distance\t\n\t// d(c) = |Z|·log|Z|/|Z'|\n\tfloat d = 0.5*sqrt(dot(z,z)/dot(dz,dz))*log(dot(z,z));\n if( di>0.5 ) d=0.0;\n\treturn d;\n}","instance":"float $(name)_xyz(vec2 uv) {\n\treturn mandelbrot(uv);\n}","name":"Mandelbrot","outputs":[{"f":"clamp($(name)_xyz(vec2($(x), $(y))+$(scale)*(2.0*$(uv)-1.0))*$(contrast), 0.0, 1.0)"}],"parameters":[{"label":"Scale","max":3,"min":0,"name":"scale","step":0.0001,"type":"float","widget":"spinbox"},{"label":"X","max":2,"min":-2,"name":"x","step":0.0001,"type":"float","widget":"spinbox"},{"label":"Y","max":2,"min":-2,"name":"y","step":0.0001,"type":"float","widget":"spinbox"},{"label":"Contrast","max":10000,"min":1,"name":"contrast","step":0.0001,"type":"float","widget":"spinbox"}]},"name":"custom_0","node_position":{"x":-211,"y":208},"parameters":{"contrast":10,"scale":1,"x":0,"y":0},"type":"custom"}]} \ No newline at end of file +{"connections":[{"from":"custom_0","from_port":0,"to":"colorize_0","to_port":0},{"from":"colorize_0","from_port":0,"to":"Material","to_port":3}],"nodes":[{"name":"Material","node_position":{"x":200,"y":0},"parameters":{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"normal_scale":1,"resolution":1,"roughness":1},"type":"material"},{"model_data":{"global":"float mandelbrot(vec2 uv) {\n float di = 1.0;\n vec2 z = vec2(0.0);\n float m2 = 0.0;\n vec2 dz = vec2(0.0);\n for( int i=0; i<200; i++ )\n {\n if (m2>1024.0 ) {\n\t\t\tdi=0.0;\n\t\t\tbreak;\n\t\t}\n\n\t\t// Z' -> 2·Z·Z' + 1\n dz = 2.0*vec2(z.x*dz.x-z.y*dz.y, z.x*dz.y + z.y*dz.x) + vec2(1.0,0.0);\n\t\t\t\n // Z -> Z² + c\t\t\t\n z = vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y ) + uv;\n\t\t\t\n m2 = dot(z,z);\n }\n\n // distance\t\n\t// d(c) = |Z|·log|Z|/|Z'|\n\tfloat d = 0.5*sqrt(dot(z,z)/dot(dz,dz))*log(dot(z,z));\n if( di>0.5 ) d=0.0;\n\treturn d;\n}","instance":"float $(name)_xyz(vec2 uv) {\n\treturn mandelbrot(uv);\n}","name":"Mandelbrot","outputs":[{"f":"clamp($(name)_xyz(vec2($(x), $(y))+$(scale)*(2.0*$(uv)-1.0))*$(contrast), 0.0, 1.0)"}],"parameters":[{"label":"Scale","max":3,"min":0,"name":"scale","step":0.0001,"type":"float","widget":"spinbox"},{"label":"X","max":2,"min":-2,"name":"x","step":0.0001,"type":"float","widget":"spinbox"},{"label":"Y","max":2,"min":-2,"name":"y","step":0.0001,"type":"float","widget":"spinbox"},{"label":"Contrast","max":10000,"min":1,"name":"contrast","step":0.0001,"type":"float","widget":"spinbox"}]},"name":"custom_0","node_position":{"x":-211,"y":208},"parameters":{"contrast":10,"scale":1,"x":0,"y":0},"type":"custom"},{"name":"colorize_0","node_position":{"x":-99.75,"y":-7.25},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0,"r":1},{"a":1,"b":0,"g":0.96875,"pos":0.2,"r":1},{"a":1,"b":0.0625,"g":1,"pos":0.4,"r":0},{"a":1,"b":1,"g":1,"pos":0.618182,"r":0},{"a":1,"b":0.965909,"g":0,"pos":0.818182,"r":0},{"a":1,"b":1,"g":0,"pos":1,"r":0.9375}],"type":"Gradient"}},"type":"colorize"}]} \ No newline at end of file diff --git a/addons/material_maker/graph_edit.gd b/addons/material_maker/graph_edit.gd index 8c2836c..2f86432 100644 --- a/addons/material_maker/graph_edit.gd +++ b/addons/material_maker/graph_edit.gd @@ -101,7 +101,7 @@ func clear_material(): func new_material(): clear_material() - create_node({name="Material", type="material"}) + create_nodes({name="Material", type="material"}) set_save_path(null) center_view() diff --git a/addons/material_maker/main_window.tscn b/addons/material_maker/main_window.tscn index 1e75135..8be1fca 100644 --- a/addons/material_maker/main_window.tscn +++ b/addons/material_maker/main_window.tscn @@ -20,7 +20,6 @@ mouse_default_cursor_shape = 0 size_flags_horizontal = 3 size_flags_vertical = 3 script = ExtResource( 1 ) -_sections_unfolded = [ "Anchor", "Grow Direction", "Margin", "Rect", "Size Flags", "custom_constants" ] [node name="VBoxContainer" type="VBoxContainer" parent="." index="0"] @@ -35,7 +34,6 @@ mouse_default_cursor_shape = 0 size_flags_horizontal = 3 size_flags_vertical = 3 alignment = 0 -_sections_unfolded = [ "Anchor", "Margin", "Size Flags" ] [node name="Menu" type="HBoxContainer" parent="VBoxContainer" index="0"] @@ -170,7 +168,6 @@ size_flags_vertical = 3 split_offset = 0 collapsed = false dragger_visibility = 0 -_sections_unfolded = [ "Size Flags" ] [node name="VBoxContainer" type="VSplitContainer" parent="VBoxContainer/HBoxContainer" index="0"] @@ -189,7 +186,6 @@ size_flags_vertical = 3 split_offset = 0 collapsed = false dragger_visibility = 0 -_sections_unfolded = [ "Size Flags" ] [node name="Library" type="Tree" parent="VBoxContainer/HBoxContainer/VBoxContainer" index="0"] diff --git a/addons/material_maker/node_base.gd b/addons/material_maker/node_base.gd index ea04e68..4747384 100644 --- a/addons/material_maker/node_base.gd +++ b/addons/material_maker/node_base.gd @@ -148,6 +148,9 @@ func reset(): generated = false generated_variants = [] +func _get_shader_code(uv, slot = 0): + pass + func get_shader_code(uv, slot = 0): var rv if slot == 0: diff --git a/addons/material_maker/nodes/blend/blend.gd b/addons/material_maker/nodes/blend/blend.gd index fe7a8bb..27d1270 100644 --- a/addons/material_maker/nodes/blend/blend.gd +++ b/addons/material_maker/nodes/blend/blend.gd @@ -22,7 +22,7 @@ func _ready(): $blend_type.add_item(BLEND_TYPES[i].name, i) initialize_properties([ $blend_type, $HBoxContainer/amount ]) -func _get_shader_code(uv): +func _get_shader_code(uv, slot = 0): var rv = { defs="", code="" } var src0 = get_source(0) var src1 = get_source(1) diff --git a/addons/material_maker/nodes/colorize/colorize.gd b/addons/material_maker/nodes/colorize/colorize.gd index eba3b08..e2deaff 100644 --- a/addons/material_maker/nodes/colorize/colorize.gd +++ b/addons/material_maker/nodes/colorize/colorize.gd @@ -4,7 +4,7 @@ extends "res://addons/material_maker/node_base.gd" func _ready(): initialize_properties([ $gradient ]) -func _get_shader_code(uv): +func _get_shader_code(uv, slot = 0): var rv = { defs="", code="" } var src = get_source() if src == null: diff --git a/addons/material_maker/nodes/combine/combine.gd b/addons/material_maker/nodes/combine/combine.gd index 851c070..45a9f98 100644 --- a/addons/material_maker/nodes/combine/combine.gd +++ b/addons/material_maker/nodes/combine/combine.gd @@ -1,7 +1,7 @@ tool extends "res://addons/material_maker/node_base.gd" -func _get_shader_code(uv): +func _get_shader_code(uv, slot = 0): var rv = { defs="", code="" } var src0 = get_source(0) var src1 = get_source(1) diff --git a/addons/material_maker/nodes/comment/comment.gd b/addons/material_maker/nodes/comment/comment.gd index c7745a5..ea52fba 100644 --- a/addons/material_maker/nodes/comment/comment.gd +++ b/addons/material_maker/nodes/comment/comment.gd @@ -1,7 +1,7 @@ tool extends "res://addons/material_maker/node_base.gd" -func _get_shader_code(uv): +func _get_shader_code(uv, slot = 0): var rv = { defs="", code="" } rv.rgb = "vec3(1.0)" return rv diff --git a/addons/material_maker/nodes/export/export.gd b/addons/material_maker/nodes/export/export.gd index 3094a8c..21fe6d9 100644 --- a/addons/material_maker/nodes/export/export.gd +++ b/addons/material_maker/nodes/export/export.gd @@ -6,7 +6,7 @@ var suffix = "suffix" func _ready(): initialize_properties([ $resolution ]) -func _get_shader_code(uv): +func _get_shader_code(uv, slot = 0): var rv = { defs="", code="", f="0.0" } var src = get_source() if src != null: diff --git a/addons/material_maker/nodes/material/material.gd b/addons/material_maker/nodes/material/material.gd index b805475..bee9320 100644 --- a/addons/material_maker/nodes/material/material.gd +++ b/addons/material_maker/nodes/material/material.gd @@ -48,7 +48,7 @@ func _rerender(): if !has_textures: do_update_materials(current_material_list) -func _get_shader_code(uv): +func _get_shader_code(uv, slot = 0): var rv = { defs="", code="", f="0.0" } var src = get_source() if src != null: diff --git a/addons/material_maker/nodes/normal_map/normal_map.gd b/addons/material_maker/nodes/normal_map/normal_map.gd index 2a3a926..aabf72a 100644 --- a/addons/material_maker/nodes/normal_map/normal_map.gd +++ b/addons/material_maker/nodes/normal_map/normal_map.gd @@ -46,7 +46,7 @@ func get_textures(): list[name] = final_texture return list -func _get_shader_code(uv): +func _get_shader_code(uv, slot = 0): var rv = { defs="", code="" } var src = get_source() if src == null: diff --git a/addons/material_maker/nodes/remote/remote.gd b/addons/material_maker/nodes/remote/remote.gd index 0808b6f..f9007e6 100644 --- a/addons/material_maker/nodes/remote/remote.gd +++ b/addons/material_maker/nodes/remote/remote.gd @@ -7,7 +7,7 @@ const ConfigControl = preload("res://addons/material_maker/widgets/linked_widget func _ready(): pass -func _get_shader_code(uv): +func _get_shader_code(uv, slot = 0): var rv = { defs="", code="" } rv.rgb = "vec3(1.0)" return rv diff --git a/addons/material_maker/nodes/transform/transform.gd b/addons/material_maker/nodes/transform/transform.gd index a342deb..040622a 100644 --- a/addons/material_maker/nodes/transform/transform.gd +++ b/addons/material_maker/nodes/transform/transform.gd @@ -5,7 +5,7 @@ func _ready(): set_slot(0, true, 0, Color(0.5, 0.5, 1), true, 0, Color(0.5, 0.5, 1)) initialize_properties([ $HBoxContainer1/translate_x, $HBoxContainer2/translate_y, $HBoxContainer3/rotate, $HBoxContainer4/scale_x, $HBoxContainer5/scale_y, $repeat ]) -func _get_shader_code(uv): +func _get_shader_code(uv, slot = 0): var rv = { defs="", code="" } var src = get_source() if src == null: diff --git a/addons/material_maker/nodes/warp/warp.gd b/addons/material_maker/nodes/warp/warp.gd index c7c0dc9..209f184 100644 --- a/addons/material_maker/nodes/warp/warp.gd +++ b/addons/material_maker/nodes/warp/warp.gd @@ -4,7 +4,7 @@ extends "res://addons/material_maker/node_base.gd" func _ready(): initialize_properties([ $amount ]) -func _get_shader_code(uv): +func _get_shader_code(uv, slot = 0): var epsilon = 0.01 var rv = { defs="", code="" } var src0 = get_source(0) diff --git a/addons/material_maker/widgets/gradient_editor.gd b/addons/material_maker/widgets/gradient_editor.gd index afc6427..8b4c463 100644 --- a/addons/material_maker/widgets/gradient_editor.gd +++ b/addons/material_maker/widgets/gradient_editor.gd @@ -77,7 +77,7 @@ func add_cursor(x, color): func _gui_input(ev): if ev is InputEventMouseButton && ev.button_index == 1 && ev.doubleclick && ev.position.y > 15: var p = max(0, min(ev.position.x, rect_size.x-GradientCursor.WIDTH)) - add_cursor(p, get_color(p)) + add_cursor(p, get_gradient_color(p)) update_value() # Showing a color picker popup to change a cursor's color @@ -103,7 +103,7 @@ func get_sorted_cursors(): array.sort_custom(GradientCursor, "sort") return array -func get_color(x): +func get_gradient_color(x): return value.get_color(x / (rect_size.x - GradientCursor.WIDTH)) func update_shader(): diff --git a/addons/material_maker/widgets/linked_widgets/linked_control_base.gd b/addons/material_maker/widgets/linked_widgets/linked_control_base.gd index 74ee94b..962d00c 100644 --- a/addons/material_maker/widgets/linked_widgets/linked_control_base.gd +++ b/addons/material_maker/widgets/linked_widgets/linked_control_base.gd @@ -34,6 +34,9 @@ func get_widget_type(widget): func _ready(): set_process_input(false) +func add_linked(node, widget): + pass + func can_link_to(c): return c != null diff --git a/addons/material_maker/widgets/tabs.gd b/addons/material_maker/widgets/tabs.gd index 284c6ef..a83da0c 100644 --- a/addons/material_maker/widgets/tabs.gd +++ b/addons/material_maker/widgets/tabs.gd @@ -9,8 +9,8 @@ signal no_more_tabs func _ready(): pass -func add_child(control): - .add_child(control) +func add_child(control, legible_unique_name = false): + .add_child(control, legible_unique_name) if !(control is Tabs): $Tabs.add_tab(control.name) move_child(control, $Tabs.get_tab_count()-1)