diff --git a/addons/material_maker/engine/gen_base.gd b/addons/material_maker/engine/gen_base.gd index 748b93f..67d0a52 100644 --- a/addons/material_maker/engine/gen_base.gd +++ b/addons/material_maker/engine/gen_base.gd @@ -91,18 +91,6 @@ func get_input_shader(input_index : int): func get_shader(output_index : int, context): return get_shader_code("UV", output_index, context); -# this will need an output index for switch -func get_globals(): - var list = [] - for i in range(10): - var source = get_source(i) - if source != null: - var source_list = source.generator.get_globals() - for g in source_list: - if list.find(g) == -1: - list.append(g) - return list - func render(output_index : int, renderer : MMGenRenderer, size : int): var context : MMGenContext = MMGenContext.new(renderer) var source = get_shader_code("UV", output_index, context) @@ -135,7 +123,6 @@ func get_shader_code(uv : String, output_index : int, context : MMGenContext): rv.rgb = "vec3("+rv.f+")" if !rv.has("rgba"): rv.rgba = "vec4("+rv.rgb+", 1.0)" - rv.globals = get_globals() return rv func _get_shader_code(uv : String, output_index : int, context : MMGenContext): diff --git a/addons/material_maker/engine/gen_convolution.gd b/addons/material_maker/engine/gen_convolution.gd index 59e1e5d..a77c801 100644 --- a/addons/material_maker/engine/gen_convolution.gd +++ b/addons/material_maker/engine/gen_convolution.gd @@ -28,7 +28,7 @@ func _get_shader_code(uv : String, output_index : int, context : MMGenContext): var genname = "o"+str(get_instance_id()) var epsilon = 1.0/pow(2, 4+parameters.size) var types = { "rgba": { type="vec4", init="vec4(0.0)" }, "rgb": { type="vec3", init="vec3(0.0)" }, "f": { type="float", init="0.0" } } - var rv = { defs="", code="", textures={} } + var rv = { globals=[], defs="", code="", textures={} } var source = get_source(0) if source == null: return rv diff --git a/addons/material_maker/engine/gen_graph.gd b/addons/material_maker/engine/gen_graph.gd index c968217..e22f1c2 100644 --- a/addons/material_maker/engine/gen_graph.gd +++ b/addons/material_maker/engine/gen_graph.gd @@ -12,44 +12,39 @@ func get_type_name(): return label func get_parameter_defs(): - var params = get_node("gen_parameters") - if params != null: - return params.get_parameter_defs() + if has_node("gen_parameters"): + return get_node("gen_parameters").get_parameter_defs() return [] func set_parameter(p, v): - var params = get_node("gen_parameters") - if params != null: - return params.set_parameter(p, v) + if has_node("gen_parameters"): + return get_node("gen_parameters").set_parameter(p, v) func get_input_defs(): - var inputs = get_node("gen_inputs") - if inputs != null: - return inputs.get_input_defs() + if has_node("gen_inputs"): + return get_node("gen_inputs").get_input_defs() return [] func get_output_defs(): - var outputs = get_node("gen_outputs") - if outputs != null: - return outputs.get_output_defs() + if has_node("gen_outputs"): + return get_node("gen_outputs").get_output_defs() return [] func source_changed(input_index : int): - var generator = get_node("gen_inputs") - if generator != null: - generator.source_changed(input_index) + if has_node("gen_inputs"): + return get_node("gen_inputs").source_changed(input_index) func get_port_source(gen_name: String, input_index: int) -> OutputPort: if gen_name == "gen_inputs": var parent = get_parent() - if parent != null and parent.get_type() == "graph": + if parent != null and parent.get_script() == get_script(): return parent.get_port_source(name, input_index) else: for c in connections: if c.to == gen_name and c.to_port == input_index: var src_gen = get_node(c.from) if src_gen != null: - if src_gen.get_type() == "graph": + if src_gen.get_script() == get_script(): return src_gen.get_port_source("gen_outputs", c.from_port) return OutputPort.new(src_gen, c.from_port) return null @@ -63,6 +58,15 @@ func get_port_targets(gen_name: String, output_index: int) -> InputPort: rv.push_back(InputPort.new(tgt_gen, c.to_port)) return rv +func add_generator(generator : MMGenBase): + var name = generator.name + var index = 1 + while has_node(name): + index += 1 + name = generator.name + "_" + str(index) + generator.name = name + add_child(generator) + func remove_generator(generator : MMGenBase): var new_connections = [] for c in connections: @@ -112,7 +116,7 @@ func _get_shader_code(uv : String, output_index : int, context : MMGenContext): while rv is GDScriptFunctionState: rv = yield(rv, "completed") return rv - return { defs="", code="", textures={} } + return { globals=[], defs="", code="", textures={} } func _serialize(data): data.label = label @@ -123,4 +127,40 @@ func _serialize(data): return data func edit(node): - node.get_parent().call_deferred("update_view", self) \ No newline at end of file + node.get_parent().call_deferred("update_view", self) + +func create_subgraph(generators): + var new_graph = get_script().new() + new_graph.name = "graph" + add_child(new_graph) + var names : Array = [] + for g in generators: + names.push_back(g.name) + remove_child(g) + new_graph.add_generator(g) + var new_graph_connections = [] + var my_new_connections = [] + var inputs = null + var outputs = null + for c in connections: + if names.find(c.from) != -1 and names.find(c.to) != -1: + new_graph_connections.push_back(c) + elif names.find(c.from) != -1: + if outputs == null: + outputs = MMGenIOs.new() + outputs.name = "gen_outputs" + new_graph.add_generator(outputs) + var port_index = outputs.ports.size() + outputs.ports.push_back( { name="port"+str(port_index), type="rgba" } ) + my_new_connections.push_back( { from=new_graph.name, from_port=port_index, to=c.to, to_port=c.to_port } ) + new_graph_connections.push_back( { from=c.from, from_port=c.from_port, to="gen_outputs", to_port=port_index } ) + elif names.find(c.to) != -1: + print("3: "+str(c)) + else: + my_new_connections.push_back(c) + connections = my_new_connections + new_graph.connections = new_graph_connections + for g in generators: + if g is MMGenRemote: + g.name = "gen_parameters" + break diff --git a/addons/material_maker/engine/gen_ios.gd b/addons/material_maker/engine/gen_ios.gd index 99ae0b3..ae530b5 100644 --- a/addons/material_maker/engine/gen_ios.gd +++ b/addons/material_maker/engine/gen_ios.gd @@ -17,9 +17,9 @@ func get_type(): return "buffer" func get_type_name(): - match mask: - 1: return "Inputs" - 2: return "Output" + match name: + "gen_inputs": return "Inputs" + "gen_outputs": return "Outputs" _: return "IOs" return "Buffer" diff --git a/addons/material_maker/engine/gen_material.gd b/addons/material_maker/engine/gen_material.gd index 05a0562..83a12f2 100644 --- a/addons/material_maker/engine/gen_material.gd +++ b/addons/material_maker/engine/gen_material.gd @@ -146,7 +146,7 @@ func update_spatial_material(m, file_prefix = null): if texture != null: m.depth_enabled = true m.depth_deep_parallax = true - m.depth_scale = parameters.depth_scale + m.depth_scale = parameters.depth_scale * 0.2 m.depth_texture = texture else: m.depth_enabled = false @@ -155,7 +155,7 @@ func export_textures(prefix, size = null): if size == null: size = int(pow(2, 8+parameters.resolution)) for t in texture_list: - var texture = generated_textures[t.texture].texture + var texture = generated_textures[t.texture] if texture != null: var image = texture.get_data() image.save_png("%s_%s.png" % [ prefix, t.texture ]) diff --git a/addons/material_maker/engine/gen_remote.gd b/addons/material_maker/engine/gen_remote.gd index 1828cdc..1df0a0b 100644 --- a/addons/material_maker/engine/gen_remote.gd +++ b/addons/material_maker/engine/gen_remote.gd @@ -14,14 +14,14 @@ func set_widgets(w): for w in widgets: var param_name = "param"+str(i) if !parameters.has(param_name): - parameters["param"+str(i)] = 0 + parameters[param_name] = 0 i += 1 func get_type(): return "remote" func get_type_name(): - return "Remote" + return "Parameters" if name == "gen_parameters" else "Remote" func get_parameter_defs(): var rv = [] @@ -68,8 +68,6 @@ func set_parameter(p, v): for w in widget.configurations[configurations[v]]: var node = parent.get_node(w.node) if node != null: - print(w.value) - print(MMType.deserialize_value(w.value)) node.set_parameter(w.widget, MMType.deserialize_value(w.value)) else: # incorrect configuration index @@ -133,9 +131,7 @@ func update_configuration(index, config_name): for w in widget.linked_widgets: var g = parent.get_node(w.node) if g != null: - print(g.parameters[w.widget]) var value = MMType.serialize_value(g.parameters[w.widget]) - print(value) c.push_back({ node=w.node, widget=w.widget, value=value }) widget.configurations[config_name] = c emit_signal("parameter_changed", "", null) diff --git a/addons/material_maker/engine/gen_shader.gd b/addons/material_maker/engine/gen_shader.gd index a50a2d4..0709cb1 100644 --- a/addons/material_maker/engine/gen_shader.gd +++ b/addons/material_maker/engine/gen_shader.gd @@ -61,6 +61,7 @@ func find_keyword_call(string, keyword): return "" func replace_input(string, context, input, type, src, default): + var required_globals = [] var required_defs = "" var required_code = "" var required_textures = {} @@ -83,11 +84,17 @@ func replace_input(string, context, input, type, src, default): while src_code is GDScriptFunctionState: src_code = yield(src_code, "completed") src_code.string = src_code[type] + # Add global definitions + for d in src_code.globals: + if required_globals.find(d) == -1: + required_globals.push_back(d) + # Add generated definitions required_defs += src_code.defs + # Add generated code required_code += src_code.code required_textures = src_code.textures string = string.replace("$%s(%s)" % [ input, uv ], src_code.string) - return { string=string, defs=required_defs, code=required_code, textures=required_textures, new_pass_required=new_pass_required } + return { string=string, globals=required_globals, defs=required_defs, code=required_code, textures=required_textures, new_pass_required=new_pass_required } func is_word_letter(l): return "azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN1234567890_".find(l) != -1 @@ -112,6 +119,7 @@ func replace_variable(string, variable, value): func subst(string, context, uv = ""): var genname = "o"+str(get_instance_id()) + var required_globals = [] var required_defs = "" var required_code = "" var required_textures = {} @@ -157,17 +165,23 @@ func subst(string, context, uv = ""): if result.new_pass_required: new_pass_required = true string = result.string + # Add global definitions + for d in result.globals: + if required_globals.find(d) == -1: + required_globals.push_back(d) + # Add generated definitions required_defs += result.defs + # Add generated code required_code += result.code for t in result.textures.keys(): required_textures[t] = result.textures[t] cont = changed and new_pass_required - return { string=string, defs=required_defs, code=required_code, textures=required_textures } + return { string=string, globals=required_globals, defs=required_defs, code=required_code, textures=required_textures } func _get_shader_code(uv : String, output_index : int, context : MMGenContext): var genname = "o"+str(get_instance_id()) var output_info = [ { field="rgba", type="vec4" }, { field="rgb", type="vec3" }, { field="f", type="float" } ] - var rv = { defs="", code="", textures={} } + var rv = { globals=[], defs="", code="", textures={} } var variant_string = uv+","+str(output_index) if shader_model != null and shader_model.has("outputs") and shader_model.outputs.size() > output_index: var output = shader_model.outputs[output_index] @@ -194,7 +208,13 @@ func _get_shader_code(uv : String, output_index : int, context : MMGenContext): var subst_output = subst(output[t.field], context, uv) while subst_output is GDScriptFunctionState: subst_output = yield(subst_output, "completed") + # Add global definitions + for d in subst_output.globals: + if rv.globals.find(d) == -1: + rv.globals.push_back(d) + # Add generated definitions rv.defs += subst_output.defs + # Add generated code rv.code += subst_output.code rv.code += "%s %s_%d_%d_%s = %s;\n" % [ t.type, genname, output_index, variant_index, t.field, subst_output.string ] for t in subst_output.textures.keys(): @@ -202,14 +222,10 @@ func _get_shader_code(uv : String, output_index : int, context : MMGenContext): for t in output_info: if output.has(t.field): rv[t.field] = "%s_%d_%d_%s" % [ genname, output_index, variant_index, t.field ] + if shader_model.has("global") && rv.globals.find(shader_model.global) == -1: + rv.globals.push_back(shader_model.global) return rv -func get_globals(): - var list = .get_globals() - if typeof(shader_model) == TYPE_DICTIONARY and shader_model.has("global") and list.find(shader_model.global) == -1: - list.append(shader_model.global) - return list - func _serialize(data): data.shader_model = shader_model return data diff --git a/addons/material_maker/engine/gen_switch.gd b/addons/material_maker/engine/gen_switch.gd index 6ed0a96..5cdc67a 100644 --- a/addons/material_maker/engine/gen_switch.gd +++ b/addons/material_maker/engine/gen_switch.gd @@ -41,3 +41,6 @@ func _get_shader_code(uv : String, output_index : int, context : MMGenContext): rv = yield(rv, "completed") return rv return { defs="", code="", textures={} } + +func _serialize(data): + return data diff --git a/addons/material_maker/engine/gen_texture.gd b/addons/material_maker/engine/gen_texture.gd index ec8d6f2..f26c10b 100644 --- a/addons/material_maker/engine/gen_texture.gd +++ b/addons/material_maker/engine/gen_texture.gd @@ -13,7 +13,7 @@ func get_output_defs(): func _get_shader_code(uv : String, output_index : int, context : MMGenContext): var genname = "o"+str(get_instance_id()) - var rv = { defs="", code="" } + var rv = { globals=[], defs="", code="" } var texture_name = genname+"_tex" var variant_index = context.get_variant(self, uv) if variant_index == -1: diff --git a/addons/material_maker/engine/loader.gd b/addons/material_maker/engine/loader.gd index b428687..c26bcd1 100644 --- a/addons/material_maker/engine/loader.gd +++ b/addons/material_maker/engine/loader.gd @@ -16,15 +16,9 @@ static func add_to_gen_graph(gen_graph, generators, connections): var g = create_gen(n) if g != null: var orig_name = g.name - var name = g.name - var index = 1 - while gen_graph.has_node(name): - index += 1 - name = g.name + "_" + str(index) - g.name = name - gen_graph.add_child(g) + gen_graph.add_generator(g) rv.generators.append(g) - gennames[orig_name] = name + gennames[orig_name] = g.name for c in connections: if gennames.has(c.from) and gennames.has(c.to): c.from = gennames[c.from] diff --git a/addons/material_maker/engine/renderer.gd b/addons/material_maker/engine/renderer.gd index 939ee6a..f9f8d02 100644 --- a/addons/material_maker/engine/renderer.gd +++ b/addons/material_maker/engine/renderer.gd @@ -26,7 +26,7 @@ static func generate_shader(src_code): for g in src_code.globals: code += g var shader_code = src_code.defs - shader_code += "void fragment() {\n" + shader_code += "\nvoid fragment() {\n" shader_code += src_code.code shader_code += "COLOR = "+src_code.rgba+";\n" shader_code += "}\n" diff --git a/addons/material_maker/examples/tiles.ptex b/addons/material_maker/examples/tiles.ptex new file mode 100644 index 0000000..47f8d89 --- /dev/null +++ b/addons/material_maker/examples/tiles.ptex @@ -0,0 +1 @@ +{"connections":[{"from":"shape","from_port":0,"to":"blend","to_port":0},{"from":"pattern","from_port":0,"to":"blend","to_port":1},{"from":"blend","from_port":0,"to":"transform","to_port":0},{"from":"transform_2","from_port":0,"to":"blend_2","to_port":1},{"from":"transform","from_port":0,"to":"blend_2","to_port":0},{"from":"bricks","from_port":1,"to":"transform_2_2","to_port":0},{"from":"transform_2_2","from_port":0,"to":"blend_3","to_port":0},{"from":"bricks","from_port":1,"to":"blend_3","to_port":1},{"from":"transform_2","from_port":0,"to":"blend_4","to_port":0},{"from":"transform","from_port":0,"to":"blend_4","to_port":1},{"from":"transform","from_port":0,"to":"transform_2","to_port":0},{"from":"blend_4","from_port":0,"to":"colorize","to_port":0},{"from":"colorize","from_port":0,"to":"blend_3","to_port":2},{"from":"blend_2","from_port":0,"to":"normal_map","to_port":0},{"from":"normal_map","from_port":0,"to":"Material","to_port":4},{"from":"blend_3","from_port":0,"to":"colorize_2","to_port":0},{"from":"colorize_2","from_port":0,"to":"Material","to_port":0}],"label":"Graph","name":"@@39","node_position":{"x":0,"y":0},"nodes":[{"name":"Material","node_position":{"x":510,"y":-55},"parameters":{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":0.45,"metallic":1,"normal_scale":2.15,"roughness":1},"type":"material"},{"name":"shape","node_position":{"x":-624.5,"y":-157.5},"parameters":{"edge":0.0625,"radius":1,"shape":0,"sides":6},"type":"shape"},{"name":"transform","node_position":{"x":-445.5,"y":-87.5},"parameters":{"repeat":true,"rotate":0,"scale_x":0.125,"scale_y":0.125,"translate_x":0,"translate_y":0},"type":"transform"},{"name":"pattern","node_position":{"x":-726.5,"y":-55.5},"parameters":{"mix":0,"x_scale":2,"x_wave":4,"y_scale":1,"y_wave":3},"type":"pattern"},{"name":"blend","node_position":{"x":-444.240479,"y":-198.5},"parameters":{"amount":1,"blend_type":2},"type":"blend"},{"name":"transform_2","node_position":{"x":-222.240479,"y":-85.5},"parameters":{"repeat":true,"rotate":0,"scale_x":1,"scale_y":1,"translate_x":0.06,"translate_y":0.06},"type":"transform"},{"name":"blend_2","node_position":{"x":-167.240479,"y":-198.5},"parameters":{"amount":1,"blend_type":9},"type":"blend"},{"name":"bricks","node_position":{"x":-506.407684,"y":150.5},"parameters":{"bevel":0,"columns":8,"mortar":0.1,"pattern":0,"repeat":1,"row_offset":0,"rows":8},"type":"bricks"},{"name":"blend_3","node_position":{"x":2.592316,"y":168.5},"parameters":{"amount":1,"blend_type":0},"type":"blend"},{"name":"transform_2_2","node_position":{"x":-262.407715,"y":140},"parameters":{"repeat":true,"rotate":0,"scale_x":1,"scale_y":1,"translate_x":0.56,"translate_y":0.56},"type":"transform"},{"name":"blend_4","node_position":{"x":5.592316,"y":65.5},"parameters":{"amount":1,"blend_type":11},"type":"blend"},{"name":"colorize","node_position":{"x":-14.407684,"y":262.5},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0,"r":0},{"a":1,"b":1,"g":1,"pos":0.072727,"r":1}],"type":"Gradient"}},"type":"colorize"},{"name":"normal_map","node_position":{"x":83.448486,"y":-87.5},"parameters":{"amount":0.5,"param0":5,"param1":0.69,"size":4},"type":"normal_map"},{"name":"colorize_2","node_position":{"x":217.448486,"y":41.5},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0.375,"pos":0,"r":1},{"a":1,"b":0,"g":0.300293,"pos":1,"r":0.640625}],"type":"Gradient"}},"type":"colorize"}],"parameters":{},"type":"graph"} \ No newline at end of file diff --git a/addons/material_maker/graph_edit.gd b/addons/material_maker/graph_edit.gd index 72d93c1..825b9a3 100644 --- a/addons/material_maker/graph_edit.gd +++ b/addons/material_maker/graph_edit.gd @@ -94,11 +94,25 @@ func clear_view(): remove_child(c) c.free() +# Center view + +func center_view(): + var center = Vector2(0, 0) + var node_count = 0 + for c in get_children(): + if c is GraphNode: + center += c.offset + 0.5*c.rect_size + node_count += 1 + if node_count > 0: + center /= node_count + scroll_offset = center - 0.5*rect_size + func update_view(g): clear_view() generator = g update_graph(generator.get_children(), generator.connections) $ButtonUp.visible = generator != top_generator + center_view() func clear_material(): if top_generator != null: @@ -176,11 +190,18 @@ func export_textures(size = null): if save_path != null: var prefix = save_path.left(save_path.rfind(".")) for c in get_children(): - if c is GraphNode and c.has_method("export_textures"): - c.export_textures(prefix, size) + if c is GraphNode and c.generator.has_method("export_textures"): + c.generator.export_textures(prefix, size) # Cut / copy / paste +func get_selected_nodes(): + var selected_nodes = [] + for n in get_children(): + if n is GraphNode and n.selected: + selected_nodes.append(n) + return selected_nodes + func remove_selection(): for c in get_children(): if c is GraphNode and c.selected and c.name != "Material": @@ -235,19 +256,6 @@ func paste(pos = Vector2(0, 0)): for c in create_nodes(data, scroll_offset+0.5*rect_size): c.selected = true -# Center view - -func center_view(): - var center = Vector2(0, 0) - var node_count = 0 - for c in get_children(): - if c is GraphNode: - center += c.offset + 0.5*c.rect_size - node_count += 1 - if node_count > 0: - center /= node_count - scroll_offset = center - 0.5*rect_size - # Delay after graph update func send_changed_signal(): @@ -272,3 +280,12 @@ func drop_data(position, data): func on_ButtonUp_pressed(): if generator != top_generator && generator.get_parent() is MMGenGraph: call_deferred("update_view", generator.get_parent()) + +# Create subgraph + +func create_subgraph(): + var generators = [] + for n in get_selected_nodes(): + generators.push_back(n.generator) + generator.create_subgraph(generators) + update_view(generator) diff --git a/addons/material_maker/main_window.gd b/addons/material_maker/main_window.gd index 1777248..00e438a 100644 --- a/addons/material_maker/main_window.gd +++ b/addons/material_maker/main_window.gd @@ -8,6 +8,7 @@ var editor_interface = null var current_tab = null onready var renderer = $Renderer +onready var projects = $VBoxContainer/HBoxContainer/Projects const MENU = [ { menu="File", command="new_material", description="New material" }, @@ -25,8 +26,8 @@ const MENU = [ { menu="Edit", command="edit_cut", shortcut="Control+X", description="Cut" }, { menu="Edit", command="edit_copy", shortcut="Control+C", description="Copy" }, { menu="Edit", command="edit_paste", shortcut="Control+V", description="Paste" }, - { menu="Tools", command="create_subgraph", description="Create subgraph" }, - { menu="Tools", command="make_selected_nodes_editable", description="Make selected nodes editable" }, + { menu="Tools", command="create_subgraph", shortcut="Control+G", description="Create subgraph" }, + { menu="Tools", command="make_selected_nodes_editable", shortcut="Control+F", description="Make selected nodes editable" }, { menu="Tools", command="add_to_user_library", description="Add selected node to user library" }, { menu="Tools", command="save_user_library", description="Save user library" }, { menu="Help", command="show_doc", description="User manual" }, @@ -48,7 +49,7 @@ func _ready(): new_material() func get_current_graph_edit(): - var graph_edit = $VBoxContainer/HBoxContainer/Projects.get_current_tab_control() + var graph_edit = projects.get_current_tab_control() if graph_edit != null and graph_edit is GraphEdit: return graph_edit return null @@ -135,8 +136,8 @@ func new_pane(): graph_edit.node_factory = $NodeFactory graph_edit.renderer = $Renderer graph_edit.editor_interface = editor_interface - $VBoxContainer/HBoxContainer/Projects.add_child(graph_edit) - $VBoxContainer/HBoxContainer/Projects.current_tab = graph_edit.get_index() + projects.add_child(graph_edit) + projects.current_tab = graph_edit.get_index() return graph_edit func new_material(): @@ -196,7 +197,7 @@ func save_material_as(): dialog.popup_centered() func close_material(): - $VBoxContainer/HBoxContainer/Projects.close_tab() + projects.close_tab() func export_material(): var graph_edit = get_current_graph_edit() @@ -215,6 +216,7 @@ func quit(): else: get_tree().quit() + func edit_cut(): var graph_edit = get_current_graph_edit() if graph_edit != null: @@ -244,21 +246,14 @@ func edit_paste_is_disabled(): func get_selected_nodes(): var graph_edit = get_current_graph_edit() if graph_edit != null: - var selected_nodes = [] - for n in graph_edit.get_children(): - if n is GraphNode and n.selected: - selected_nodes.append(n) - return selected_nodes + return graph_edit.get_selected_nodes() else: return [] func create_subgraph(): var graph_edit = get_current_graph_edit() - var selected_nodes = get_selected_nodes() - if !selected_nodes.empty(): - for n in selected_nodes: - print(n.name) - # TODO ! + if graph_edit != null: + graph_edit.create_subgraph() func make_selected_nodes_editable(): var selected_nodes = get_selected_nodes() @@ -326,34 +321,39 @@ func _on_LoadRecent_id_pressed(id): # Preview func update_preview(): - var material_node = $VBoxContainer/HBoxContainer/Projects.get_current_tab_control().get_node("node_Material") - if material_node != null: - var status = material_node.generator.render_textures(renderer) - while status is GDScriptFunctionState: - status = yield(status, "completed") - material_node.generator.update_materials($VBoxContainer/HBoxContainer/VBoxContainer/Preview.get_materials()) update_preview_2d() + update_preview_3d() func update_preview_2d(node = null): - var graph_edit = $VBoxContainer/HBoxContainer/Projects.get_current_tab_control() - var preview = $VBoxContainer/HBoxContainer/VBoxContainer/Preview - if node == null: - for n in graph_edit.get_children(): - if n is GraphNode and n.selected: - node = n - break - if node != null: - var status = node.generator.render(0, renderer, 1024) + var graph_edit = get_current_graph_edit() + if graph_edit != null: + var preview = $VBoxContainer/HBoxContainer/VBoxContainer/Preview + if node == null: + for n in graph_edit.get_children(): + if n is GraphNode and n.selected: + node = n + break + if node != null: + var status = node.generator.render(0, renderer, 1024) + while status is GDScriptFunctionState: + status = yield(status, "completed") + if status: + var image = renderer.get_texture().get_data() + var tex = ImageTexture.new() + tex.create_from_image(image) + preview.set_2d(tex) + +func update_preview_3d(): + var graph_edit = get_current_graph_edit() + if graph_edit != null and graph_edit.top_generator != null and graph_edit.top_generator.has_node("Material"): + var gen_material = graph_edit.top_generator.get_node("Material") + var status = gen_material.render_textures(renderer) while status is GDScriptFunctionState: status = yield(status, "completed") - if status: - var image = renderer.get_texture().get_data() - var tex = ImageTexture.new() - tex.create_from_image(image) - preview.set_2d(tex) + gen_material.update_materials($VBoxContainer/HBoxContainer/VBoxContainer/Preview.get_materials()) func _on_Projects_tab_changed(tab): - var new_tab = $VBoxContainer/HBoxContainer/Projects.get_current_tab_control() + var new_tab = projects.get_current_tab_control() if new_tab != current_tab: if new_tab != null: for c in get_incoming_connections(): diff --git a/addons/material_maker/main_window.tscn b/addons/material_maker/main_window.tscn index 8812090..9afebab 100644 --- a/addons/material_maker/main_window.tscn +++ b/addons/material_maker/main_window.tscn @@ -42,14 +42,14 @@ margin_left = 79.0 margin_right = 125.0 margin_bottom = 20.0 text = "Tools" -items = [ "Make selected nodes editable", null, 0, false, false, 15, 0, null, "", false, "Add selected node to user library", null, 0, false, false, 16, 0, null, "", false, "Save user library", null, 0, false, false, 17, 0, null, "", false ] +items = [ "Create subgraph", null, 0, false, false, 15, 268435527, null, "", false, "Make selected nodes editable", null, 0, false, false, 16, 268435526, null, "", false, "Add selected node to user library", null, 0, false, false, 17, 0, null, "", false, "Save user library", null, 0, false, false, 18, 0, null, "", false ] [node name="Help" type="MenuButton" parent="VBoxContainer/Menu"] margin_left = 129.0 margin_right = 171.0 margin_bottom = 20.0 text = "Help" -items = [ "User manual", null, 0, false, false, 18, 0, null, "", false, "Report a bug", null, 0, false, false, 19, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "About", null, 0, false, false, 21, 0, null, "", false ] +items = [ "User manual", null, 0, false, false, 19, 0, null, "", false, "Report a bug", null, 0, false, false, 20, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "About", null, 0, false, false, 22, 0, null, "", false ] [node name="HBoxContainer" type="HSplitContainer" parent="VBoxContainer"] margin_top = 24.0 @@ -100,6 +100,7 @@ debug_path = null [node name="NodeFactory" type="Node" parent="."] script = ExtResource( 6 ) +[connection signal="need_update" from="VBoxContainer/HBoxContainer/VBoxContainer/Preview" to="." method="update_preview_3d"] [connection signal="no_more_tabs" from="VBoxContainer/HBoxContainer/Projects" to="." method="new_material"] [connection signal="resized" from="VBoxContainer/HBoxContainer/Projects" to="VBoxContainer/HBoxContainer/Projects" method="_on_Projects_resized"] [connection signal="tab_changed" from="VBoxContainer/HBoxContainer/Projects" to="." method="_on_Projects_tab_changed"] diff --git a/addons/material_maker/nodes/generic.gd b/addons/material_maker/nodes/generic.gd index 332c03a..4743048 100644 --- a/addons/material_maker/nodes/generic.gd +++ b/addons/material_maker/nodes/generic.gd @@ -50,7 +50,8 @@ func initialize_properties(): if parameter_names.find(c) == -1: continue var o = controls[c] - on_parameter_changed(c, generator.parameters[c]) + if generator.parameters.has(c): + on_parameter_changed(c, generator.parameters[c]) if o is LineEdit: o.connect("text_changed", self, "_on_text_changed", [ o.name ]) elif o is SpinBox: @@ -134,11 +135,8 @@ func update_node(): # Clean node var custom_node_buttons = null for c in get_children(): - if c.name != "CustomNodeButtons": - remove_child(c) - c.queue_free() - else: - custom_node_buttons = c + c.queue_free() + yield(get_tree(), "idle_frame") rect_size = Vector2(0, 0) # Rebuild node title = generator.get_type_name() diff --git a/addons/material_maker/nodes/kaleidoscope.mmg b/addons/material_maker/nodes/kaleidoscope.mmg new file mode 100644 index 0000000..02864d2 --- /dev/null +++ b/addons/material_maker/nodes/kaleidoscope.mmg @@ -0,0 +1 @@ +{"name":"kaleidoscope","node_position":{"x":0,"y":0},"parameters":{"count":7,"direction":0,"offset":0},"shader_model":{"global":"vec2 kal_rotate(vec2 uv, float count) {\n\tuv -= vec2(0.5);\n\tfloat l = length(uv);\n\tfloat a = mod(atan(uv.y, uv.x), 6.28318530718/count);\n\treturn vec2(0.5)+l*vec2(cos(a), sin(a));\n}","inputs":[{"default":"vec4($uv, 0, 1)","label":"","name":"i","type":"rgba"}],"instance":"","name":"Kaleidoscope","outputs":[{"rgba":"$i(kal_rotate($uv, $count))","type":"rgba"}],"parameters":[{"default":0,"label":"","max":10,"min":2,"name":"count","step":1,"type":"float","widget":"spinbox"}]},"type":"shader"} \ No newline at end of file diff --git a/addons/material_maker/nodes/normal_map.mmg b/addons/material_maker/nodes/normal_map.mmg index 137b545..7e7b5fd 100644 --- a/addons/material_maker/nodes/normal_map.mmg +++ b/addons/material_maker/nodes/normal_map.mmg @@ -1 +1 @@ -{"connections":[{"from":"nm_convolution","from_port":0,"to":"nm_postprocess","to_port":0},{"from":"nm_postprocess","from_port":0,"to":"gen_outputs","to_port":0},{"from":"gen_inputs","from_port":0,"to":"buffer","to_port":0},{"from":"buffer","from_port":0,"to":"nm_convolution","to_port":0}],"label":"Normal Map","name":"normal_map","node_position":{"x":0,"y":0},"nodes":[{"mask":3,"name":"gen_inputs","node_position":{"x":-839.25,"y":177.25},"parameters":{"size":4},"ports":[{"name":"in","type":"rgba"}],"type":"ios"},{"mask":3,"name":"gen_outputs","node_position":{"x":-434.25,"y":318.25},"parameters":{"size":4},"ports":[{"name":"in","type":"rgba"}],"type":"ios"},{"convolution_params":{"input_type":"f","matrix":[[[-1,-1,0],[0,-2,0],[1,-1,0]],[[-2,0,0],0,[2,0,0]],[[-1,1,0],[0,2,0],[1,1,0]]],"output_type":"rgb","x":1,"y":1},"name":"nm_convolution","node_position":{"x":-669.25,"y":245.25},"parameters":{"size":5},"type":"shader"},{"name":"nm_postprocess","node_position":{"x":-678.25,"y":315.25},"parameters":{"amount":0.99,"size":5},"shader_model":{"global":"","inputs":[{"default":"vec3(0.0)","label":"","name":"in","type":"rgb"}],"instance":"","name":"NormalMapPostProcess","outputs":[{"rgb":"0.5*normalize($in($uv)*$amount*$size/128.0-vec3(0.0, 0.0, 1.0))+vec3(0.5)","type":"rgb"}],"parameters":[{"default":8,"first":4,"label":"","last":11,"name":"size","type":"size"},{"default":1,"label":"","max":2,"min":0,"name":"amount","step":0.005,"type":"float"}]},"type":"shader"},{"name":"buffer","node_position":{"x":-669.663818,"y":174.60614},"parameters":{"size":5},"type":"buffer"},{"name":"gen_parameters","node_position":{"x":-702.910156,"y":23.083313},"parameters":{"param0":5,"param1":0.99},"type":"remote","widgets":[{"label":"Unnamed","linked_widgets":[{"node":"buffer","widget":"size"},{"node":"nm_convolution","widget":"size"},{"node":"nm_postprocess","widget":"size"}],"type":"linked_control"},{"label":"Unnamed","linked_widgets":[{"node":"nm_postprocess","widget":"amount"}],"type":"linked_control"}]}],"parameters":{"amount":0.35,"param0":5,"param1":0.99,"size":4},"type":"graph"} \ No newline at end of file +{"connections":[{"from":"nm_convolution","from_port":0,"to":"nm_postprocess","to_port":0},{"from":"nm_postprocess","from_port":0,"to":"gen_outputs","to_port":0},{"from":"gen_inputs","from_port":0,"to":"buffer","to_port":0},{"from":"buffer","from_port":0,"to":"nm_convolution","to_port":0}],"label":"Normal Map","name":"normal_map","node_position":{"x":0,"y":0},"nodes":[{"mask":3,"name":"gen_inputs","node_position":{"x":-839.25,"y":177.25},"parameters":{"size":4},"ports":[{"name":"in","type":"rgba"}],"type":"ios"},{"mask":3,"name":"gen_outputs","node_position":{"x":-434.25,"y":318.25},"parameters":{"size":4},"ports":[{"name":"in","type":"rgba"}],"type":"ios"},{"convolution_params":{"input_type":"f","matrix":[[[-1,-1,0],[0,-2,0],[1,-1,0]],[[-2,0,0],0,[2,0,0]],[[-1,1,0],[0,2,0],[1,1,0]]],"output_type":"rgb","x":1,"y":1},"name":"nm_convolution","node_position":{"x":-669.25,"y":245.25},"parameters":{"size":5},"type":"shader"},{"name":"nm_postprocess","node_position":{"x":-678.25,"y":315.25},"parameters":{"amount":0.99,"size":5},"shader_model":{"global":"","inputs":[{"default":"vec3(0.0)","label":"","name":"in","type":"rgb"}],"instance":"","name":"NormalMapPostProcess","outputs":[{"rgb":"0.5*normalize($in($uv)*$amount*$size/128.0-vec3(0.0, 0.0, 1.0))+vec3(0.5)","type":"rgb"}],"parameters":[{"default":9,"first":4,"label":"","last":11,"name":"size","type":"size"},{"default":1,"label":"","max":2,"min":0,"name":"amount","step":0.005,"type":"float"}]},"type":"shader"},{"name":"buffer","node_position":{"x":-669.663818,"y":174.60614},"parameters":{"size":5},"type":"buffer"},{"name":"gen_parameters","node_position":{"x":-713.910156,"y":24.083313},"parameters":{"param0":5,"param1":0.99},"type":"remote","widgets":[{"label":"Unnamed","linked_widgets":[{"node":"buffer","widget":"size"},{"node":"nm_convolution","widget":"size"},{"node":"nm_postprocess","widget":"size"}],"type":"linked_control"},{"label":"Unnamed","linked_widgets":[{"node":"nm_postprocess","widget":"amount"}],"type":"linked_control"}]}],"parameters":{"amount":0.35,"param0":5,"param1":0.99,"size":4},"type":"graph"} \ No newline at end of file diff --git a/addons/material_maker/nodes/remote.gd b/addons/material_maker/nodes/remote.gd index 42d6ebe..f7cc1ee 100644 --- a/addons/material_maker/nodes/remote.gd +++ b/addons/material_maker/nodes/remote.gd @@ -28,6 +28,7 @@ func update_node(): for c in grid.get_children(): c.queue_free() yield(get_tree(), "idle_frame") + title = generator.get_type_name() controls = {} for p in generator.get_parameter_defs(): var control = create_parameter_control(p) @@ -101,7 +102,6 @@ func _on_Link_pressed(index): link.pick(grid.get_child(index*4+1), generator, index) func _on_Remote_resize_request(new_minsize): - print("_on_Remote_resize_request") rect_size = new_minsize func _on_HBoxContainer_minimum_size_changed(): diff --git a/addons/material_maker/preview.gd b/addons/material_maker/preview.gd index bd97705..89b0d8a 100644 --- a/addons/material_maker/preview.gd +++ b/addons/material_maker/preview.gd @@ -7,13 +7,18 @@ const ENVIRONMENTS = [ "experiment", "lobby", "night", "park", "schelde" ] +onready var objects = $MaterialPreview/Objects +onready var current_object = objects.get_child(0) + +signal need_update + func _ready(): - var m - m = $MaterialPreview/Objects/Cube.get_surface_material(0).duplicate() - $MaterialPreview/Objects/Cube.set_surface_material(0, m) - $MaterialPreview/Objects/Cylinder.set_surface_material(0, m) - m = $MaterialPreview/Objects/Sphere.get_surface_material(0).duplicate() - $MaterialPreview/Objects/Sphere.set_surface_material(0, m) + current_object.visible = true + $Config/Model.clear() + for o in objects.get_children(): + var m = o.get_surface_material(0) + o.set_surface_material(0, m.duplicate()) + $Config/Model.add_item(o.name) $ObjectRotate.play("rotate") $Preview2D.material = $Preview2D.material.duplicate(true) _on_Environment_item_selected($Config/Environment.selected) @@ -23,12 +28,13 @@ func _on_Environment_item_selected(id): $MaterialPreview/WorldEnvironment.environment.background_sky.panorama = load("res://addons/material_maker/panoramas/"+ENVIRONMENTS[id]+".hdr") func _on_Model_item_selected(id): - var model = $Config/Model.get_item_text(id) - for c in $MaterialPreview/Objects.get_children(): - c.visible = (c.get_name() == model) + current_object.visible = false + current_object = objects.get_child(id) + current_object.visible = true + emit_signal("need_update") func get_materials(): - return [ $MaterialPreview/Objects/Cube.get_surface_material(0), $MaterialPreview/Objects/Sphere.get_surface_material(0) ] + return [ current_object.get_surface_material(0) ] func set_2d(tex: Texture): $Preview2D.material.set_shader_param("tex", tex) @@ -45,6 +51,4 @@ func _on_Preview_resized(): func _on_Preview2D_gui_input(ev : InputEvent): if ev is InputEventMouseButton and ev.button_index == 1 and ev.pressed: preview_maximized = !preview_maximized - _on_Preview_resized() - - + _on_Preview_resized() \ No newline at end of file diff --git a/addons/material_maker/preview.tscn b/addons/material_maker/preview.tscn index 1474b4a..a80ae59 100644 --- a/addons/material_maker/preview.tscn +++ b/addons/material_maker/preview.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=13 format=2] +[gd_scene load_steps=9 format=2] [ext_resource path="res://addons/material_maker/preview.gd" type="Script" id=1] -[ext_resource path="res://addons/material_maker/panoramas/park.hdr" type="Texture" id=2] +[ext_resource path="res://addons/material_maker/preview_objects.tscn" type="PackedScene" id=2] +[ext_resource path="res://addons/material_maker/panoramas/park.hdr" type="Texture" id=3] [sub_resource type="Animation" id=1] loop = true @@ -18,77 +19,15 @@ tracks/0/keys = { "values": [ Vector3( 0, 0, 0 ), Vector3( 0, 360, 0 ) ] } -[sub_resource type="ArrayMesh" id=2] -surfaces/0 = { -"aabb": AABB( -1, -1, -1, 2.00001, 2, 2 ), -"array_data": PoolByteArray( 0, 60, 0, 188, 255, 187, 0, 60, 0, 129, 0, 0, 126, 0, 0, 129, 252, 59, 251, 59, 0, 188, 0, 188, 255, 59, 0, 60, 0, 129, 0, 0, 127, 0, 0, 129, 4, 18, 60, 25, 0, 60, 0, 188, 0, 60, 0, 60, 0, 129, 0, 0, 127, 0, 0, 129, 252, 59, 60, 25, 255, 187, 0, 188, 0, 188, 0, 60, 0, 129, 0, 0, 127, 0, 0, 129, 4, 18, 251, 59, 0, 60, 0, 60, 255, 187, 0, 60, 0, 127, 0, 0, 0, 0, 129, 129, 252, 59, 251, 59, 0, 188, 0, 60, 255, 59, 0, 60, 0, 127, 0, 0, 0, 0, 129, 129, 4, 18, 60, 25, 255, 187, 0, 60, 0, 188, 0, 60, 0, 127, 0, 0, 0, 0, 129, 129, 252, 59, 60, 25, 255, 59, 0, 60, 0, 60, 0, 60, 0, 127, 0, 0, 0, 0, 129, 129, 4, 18, 251, 59, 0, 60, 0, 188, 255, 187, 0, 60, 127, 0, 0, 0, 0, 0, 129, 129, 252, 59, 251, 59, 255, 59, 0, 60, 0, 60, 0, 60, 127, 0, 0, 0, 0, 0, 129, 129, 4, 18, 60, 25, 0, 60, 0, 60, 255, 187, 0, 60, 127, 0, 0, 0, 0, 0, 129, 129, 252, 59, 60, 25, 0, 60, 0, 188, 0, 60, 0, 60, 127, 0, 0, 0, 0, 0, 129, 129, 4, 18, 251, 59, 0, 60, 0, 188, 0, 60, 0, 60, 0, 0, 127, 0, 127, 0, 0, 129, 252, 59, 251, 59, 0, 188, 0, 60, 255, 59, 0, 60, 0, 0, 127, 0, 127, 0, 0, 129, 4, 18, 60, 25, 255, 59, 0, 60, 0, 60, 0, 60, 0, 0, 127, 0, 127, 0, 0, 129, 252, 59, 60, 25, 0, 188, 0, 188, 255, 59, 0, 60, 0, 0, 127, 0, 126, 0, 0, 129, 4, 18, 251, 59, 0, 188, 0, 188, 255, 59, 0, 60, 129, 0, 0, 0, 0, 0, 127, 129, 252, 59, 251, 59, 255, 187, 0, 60, 0, 188, 0, 60, 129, 0, 0, 0, 0, 0, 126, 129, 4, 18, 60, 25, 0, 188, 0, 60, 255, 59, 0, 60, 129, 0, 0, 0, 0, 0, 127, 129, 252, 59, 60, 25, 255, 187, 0, 188, 0, 188, 0, 60, 129, 0, 0, 0, 0, 0, 127, 129, 4, 18, 251, 59, 0, 60, 0, 60, 255, 187, 0, 60, 0, 0, 129, 0, 129, 0, 0, 129, 4, 18, 60, 25, 255, 187, 0, 188, 0, 188, 0, 60, 0, 0, 129, 0, 130, 0, 0, 129, 252, 59, 251, 59, 0, 60, 0, 188, 255, 187, 0, 60, 0, 0, 129, 0, 129, 0, 0, 129, 4, 18, 251, 59, 255, 187, 0, 60, 0, 188, 0, 60, 0, 0, 129, 0, 129, 0, 0, 129, 252, 59, 60, 25 ), -"array_index_data": PoolByteArray( 0, 0, 1, 0, 2, 0, 0, 0, 3, 0, 1, 0, 4, 0, 5, 0, 6, 0, 4, 0, 7, 0, 5, 0, 8, 0, 9, 0, 10, 0, 8, 0, 11, 0, 9, 0, 12, 0, 13, 0, 14, 0, 12, 0, 15, 0, 13, 0, 16, 0, 17, 0, 18, 0, 16, 0, 19, 0, 17, 0, 20, 0, 21, 0, 22, 0, 20, 0, 23, 0, 21, 0 ), -"blend_shape_data": [ ], -"format": 98071, -"index_count": 36, -"name": "Material", -"primitive": 4, -"skeleton_aabb": [ ], -"vertex_count": 24 -} - -[sub_resource type="SpatialMaterial" id=3] -metallic = 1.0 -metallic_specular = 1.0 -ao_enabled = true -ao_light_affect = 0.0 -ao_on_uv2 = false -ao_texture_channel = 0 -depth_enabled = true -depth_scale = 0.5 -depth_deep_parallax = true -depth_min_layers = 8 -depth_max_layers = 32 -depth_flip_tangent = false -depth_flip_binormal = false - -[sub_resource type="ArrayMesh" id=4] -surfaces/0 = { -"aabb": AABB( -1, -1, -1, 2, 2, 2 ), -"array_data": PoolByteArray( 0, 0, 0, 188, 0, 188, 0, 60, 0, 172, 162, 0, 129, 0, 0, 129, 201, 58, 209, 59, 31, 54, 0, 60, 100, 187, 0, 60, 36, 84, 169, 0, 139, 0, 208, 129, 73, 57, 198, 37, 0, 0, 0, 60, 0, 188, 0, 60, 0, 84, 162, 0, 129, 0, 0, 129, 201, 58, 198, 37, 31, 54, 0, 188, 100, 187, 0, 60, 36, 172, 169, 0, 139, 0, 208, 129, 73, 57, 209, 59, 168, 57, 0, 60, 168, 185, 0, 60, 67, 84, 189, 0, 167, 0, 167, 129, 147, 55, 198, 37, 168, 57, 0, 188, 168, 185, 0, 60, 67, 172, 189, 0, 167, 0, 167, 129, 147, 55, 209, 59, 100, 59, 0, 60, 31, 182, 0, 60, 87, 84, 220, 0, 208, 0, 139, 129, 147, 52, 198, 37, 100, 59, 0, 188, 31, 182, 0, 60, 87, 172, 220, 0, 208, 0, 139, 129, 147, 52, 209, 59, 0, 60, 0, 60, 0, 0, 0, 60, 94, 84, 0, 0, 0, 0, 130, 129, 77, 46, 198, 37, 0, 60, 0, 188, 0, 0, 0, 60, 94, 172, 0, 0, 0, 0, 129, 129, 77, 46, 209, 59, 100, 59, 0, 60, 31, 54, 0, 60, 87, 84, 36, 0, 48, 0, 139, 129, 178, 173, 198, 37, 100, 59, 0, 188, 31, 54, 0, 60, 87, 172, 36, 0, 48, 0, 139, 129, 178, 173, 209, 59, 168, 57, 0, 60, 168, 57, 0, 60, 67, 84, 67, 0, 89, 0, 167, 129, 108, 180, 198, 37, 168, 57, 0, 188, 168, 57, 0, 60, 67, 172, 67, 0, 89, 0, 167, 129, 108, 180, 209, 59, 31, 54, 0, 60, 100, 59, 0, 60, 36, 84, 87, 0, 117, 0, 208, 129, 108, 183, 198, 37, 31, 54, 0, 188, 100, 59, 0, 60, 36, 172, 87, 0, 117, 0, 208, 129, 108, 183, 209, 59, 0, 0, 0, 60, 0, 60, 0, 60, 0, 84, 94, 0, 127, 0, 0, 129, 54, 185, 198, 37, 0, 0, 0, 188, 0, 60, 0, 60, 0, 172, 94, 0, 127, 0, 0, 129, 54, 185, 209, 59, 31, 182, 0, 60, 100, 59, 0, 60, 220, 84, 87, 0, 117, 0, 48, 129, 182, 186, 198, 37, 31, 182, 0, 188, 100, 59, 0, 60, 220, 172, 87, 0, 117, 0, 48, 129, 182, 186, 209, 59, 168, 185, 0, 60, 168, 57, 0, 60, 189, 84, 67, 0, 89, 0, 89, 129, 27, 188, 198, 37, 168, 185, 0, 188, 168, 57, 0, 60, 189, 172, 67, 0, 89, 0, 89, 129, 27, 188, 209, 59, 100, 187, 0, 60, 31, 54, 0, 60, 169, 84, 36, 0, 48, 0, 117, 129, 219, 188, 198, 37, 100, 187, 0, 188, 31, 54, 0, 60, 169, 172, 36, 0, 48, 0, 117, 129, 219, 188, 209, 59, 0, 188, 0, 60, 0, 0, 0, 60, 162, 84, 0, 0, 11, 12, 125, 129, 155, 189, 198, 37, 0, 188, 0, 188, 0, 0, 0, 60, 162, 172, 0, 0, 11, 244, 125, 129, 155, 189, 209, 59, 0, 188, 0, 188, 0, 0, 0, 60, 162, 172, 0, 0, 245, 12, 125, 129, 100, 62, 209, 59, 100, 187, 0, 60, 31, 182, 0, 60, 169, 84, 220, 0, 208, 0, 117, 129, 164, 61, 198, 37, 0, 188, 0, 60, 0, 0, 0, 60, 162, 84, 0, 0, 245, 244, 125, 129, 100, 62, 198, 37, 100, 187, 0, 188, 31, 182, 0, 60, 169, 172, 220, 0, 208, 0, 117, 129, 164, 61, 209, 59, 168, 185, 0, 60, 168, 185, 0, 60, 189, 84, 189, 0, 167, 0, 89, 129, 228, 60, 198, 37, 168, 185, 0, 188, 168, 185, 0, 60, 189, 172, 189, 0, 167, 0, 89, 129, 228, 60, 209, 59, 31, 54, 0, 60, 100, 187, 0, 60, 0, 127, 0, 0, 127, 0, 0, 129, 81, 57, 138, 43, 31, 182, 0, 60, 100, 187, 0, 60, 0, 127, 0, 0, 127, 0, 0, 129, 201, 52, 138, 43, 0, 0, 0, 60, 0, 188, 0, 60, 0, 127, 0, 0, 127, 0, 0, 129, 181, 55, 198, 37, 168, 185, 0, 60, 168, 185, 0, 60, 0, 127, 0, 0, 127, 0, 0, 129, 157, 48, 50, 49, 100, 187, 0, 60, 31, 182, 0, 60, 0, 127, 0, 0, 127, 0, 0, 129, 56, 41, 19, 53, 0, 188, 0, 60, 0, 0, 0, 60, 0, 127, 0, 0, 127, 0, 0, 129, 140, 28, 0, 56, 100, 187, 0, 60, 31, 54, 0, 60, 0, 127, 0, 0, 127, 0, 0, 129, 56, 41, 118, 57, 168, 185, 0, 60, 168, 57, 0, 60, 0, 127, 0, 0, 127, 0, 0, 129, 157, 48, 179, 58, 31, 182, 0, 60, 100, 59, 0, 60, 0, 127, 0, 0, 127, 0, 0, 129, 201, 52, 135, 59, 0, 0, 0, 60, 0, 60, 0, 60, 0, 127, 0, 0, 127, 0, 0, 129, 181, 55, 209, 59, 31, 54, 0, 60, 100, 59, 0, 60, 0, 127, 0, 0, 127, 0, 0, 129, 81, 57, 135, 59, 168, 57, 0, 60, 168, 57, 0, 60, 0, 127, 0, 0, 127, 0, 0, 129, 142, 58, 179, 58, 100, 59, 0, 60, 31, 54, 0, 60, 0, 127, 0, 0, 127, 0, 0, 129, 98, 59, 118, 57, 0, 60, 0, 60, 0, 0, 0, 60, 0, 127, 0, 0, 127, 0, 0, 129, 172, 59, 0, 56, 100, 59, 0, 60, 31, 182, 0, 60, 0, 127, 0, 0, 127, 0, 0, 129, 98, 59, 19, 53, 168, 57, 0, 60, 168, 185, 0, 60, 0, 127, 0, 0, 127, 0, 0, 129, 142, 58, 50, 49, 31, 182, 0, 60, 100, 187, 0, 60, 220, 84, 169, 0, 139, 0, 48, 129, 36, 60, 198, 37, 31, 182, 0, 188, 100, 187, 0, 60, 220, 172, 169, 0, 139, 0, 48, 129, 36, 60, 209, 59, 0, 0, 0, 188, 0, 188, 0, 60, 0, 129, 0, 0, 127, 0, 0, 127, 181, 55, 198, 37, 168, 57, 0, 188, 168, 185, 0, 60, 0, 129, 0, 0, 127, 0, 0, 127, 142, 58, 50, 49, 31, 54, 0, 188, 100, 187, 0, 60, 0, 129, 0, 0, 127, 0, 0, 127, 81, 57, 138, 43, 100, 59, 0, 188, 31, 182, 0, 60, 0, 129, 0, 0, 127, 0, 0, 127, 98, 59, 19, 53, 0, 60, 0, 188, 0, 0, 0, 60, 0, 129, 0, 0, 127, 0, 0, 127, 172, 59, 0, 56, 100, 59, 0, 188, 31, 54, 0, 60, 0, 129, 0, 0, 127, 0, 0, 127, 98, 59, 118, 57, 168, 57, 0, 188, 168, 57, 0, 60, 0, 129, 0, 0, 127, 0, 0, 127, 142, 58, 179, 58, 31, 54, 0, 188, 100, 59, 0, 60, 0, 129, 0, 0, 127, 0, 0, 127, 81, 57, 135, 59, 0, 0, 0, 188, 0, 60, 0, 60, 0, 129, 0, 0, 127, 0, 0, 127, 181, 55, 209, 59, 31, 182, 0, 188, 100, 59, 0, 60, 0, 129, 0, 0, 127, 0, 0, 127, 201, 52, 135, 59, 168, 185, 0, 188, 168, 57, 0, 60, 0, 129, 0, 0, 127, 0, 0, 127, 157, 48, 179, 58, 100, 187, 0, 188, 31, 54, 0, 60, 0, 129, 0, 0, 127, 0, 0, 127, 56, 41, 118, 57, 0, 188, 0, 188, 0, 0, 0, 60, 0, 129, 0, 0, 127, 0, 0, 127, 140, 28, 0, 56, 100, 187, 0, 188, 31, 182, 0, 60, 0, 129, 0, 0, 127, 0, 0, 127, 56, 41, 19, 53, 168, 185, 0, 188, 168, 185, 0, 60, 0, 129, 0, 0, 127, 0, 0, 127, 157, 48, 50, 49, 31, 182, 0, 188, 100, 187, 0, 60, 0, 129, 0, 0, 127, 0, 0, 127, 201, 52, 138, 43 ), -"array_index_data": PoolByteArray( 0, 0, 1, 0, 2, 0, 0, 0, 3, 0, 1, 0, 3, 0, 4, 0, 1, 0, 3, 0, 5, 0, 4, 0, 5, 0, 6, 0, 4, 0, 5, 0, 7, 0, 6, 0, 7, 0, 8, 0, 6, 0, 7, 0, 9, 0, 8, 0, 9, 0, 10, 0, 8, 0, 9, 0, 11, 0, 10, 0, 11, 0, 12, 0, 10, 0, 11, 0, 13, 0, 12, 0, 13, 0, 14, 0, 12, 0, 13, 0, 15, 0, 14, 0, 15, 0, 16, 0, 14, 0, 15, 0, 17, 0, 16, 0, 17, 0, 18, 0, 16, 0, 17, 0, 19, 0, 18, 0, 19, 0, 20, 0, 18, 0, 19, 0, 21, 0, 20, 0, 21, 0, 22, 0, 20, 0, 21, 0, 23, 0, 22, 0, 23, 0, 24, 0, 22, 0, 23, 0, 25, 0, 24, 0, 26, 0, 27, 0, 28, 0, 26, 0, 29, 0, 27, 0, 29, 0, 30, 0, 27, 0, 29, 0, 31, 0, 30, 0, 32, 0, 33, 0, 34, 0, 32, 0, 35, 0, 33, 0, 32, 0, 36, 0, 35, 0, 32, 0, 37, 0, 36, 0, 32, 0, 38, 0, 37, 0, 32, 0, 39, 0, 38, 0, 32, 0, 40, 0, 39, 0, 32, 0, 41, 0, 40, 0, 32, 0, 42, 0, 41, 0, 32, 0, 43, 0, 42, 0, 32, 0, 44, 0, 43, 0, 32, 0, 45, 0, 44, 0, 32, 0, 46, 0, 45, 0, 32, 0, 47, 0, 46, 0, 31, 0, 48, 0, 30, 0, 31, 0, 49, 0, 48, 0, 49, 0, 2, 0, 48, 0, 49, 0, 0, 0, 2, 0, 50, 0, 51, 0, 52, 0, 50, 0, 53, 0, 51, 0, 50, 0, 54, 0, 53, 0, 50, 0, 55, 0, 54, 0, 50, 0, 56, 0, 55, 0, 50, 0, 57, 0, 56, 0, 50, 0, 58, 0, 57, 0, 50, 0, 59, 0, 58, 0, 50, 0, 60, 0, 59, 0, 50, 0, 61, 0, 60, 0, 50, 0, 62, 0, 61, 0, 50, 0, 63, 0, 62, 0, 50, 0, 64, 0, 63, 0, 50, 0, 65, 0, 64, 0 ), -"blend_shape_data": [ ], -"format": 98071, -"index_count": 180, -"primitive": 4, -"skeleton_aabb": [ ], -"vertex_count": 66 -} - -[sub_resource type="SphereMesh" id=5] -radius = 1.5 -height = 3.0 - -[sub_resource type="SpatialMaterial" id=6] -metallic = 1.0 -metallic_specular = 1.0 -ao_enabled = true -ao_light_affect = 0.0 -ao_on_uv2 = false -ao_texture_channel = 0 -depth_enabled = true -depth_scale = 0.5 -depth_deep_parallax = true -depth_min_layers = 8 -depth_max_layers = 32 -depth_flip_tangent = false -depth_flip_binormal = false -uv1_scale = Vector3( -5, -5, 5 ) - -[sub_resource type="PanoramaSky" id=7] +[sub_resource type="PanoramaSky" id=10] radiance_size = 2 -panorama = ExtResource( 2 ) +panorama = ExtResource( 3 ) -[sub_resource type="Environment" id=8] +[sub_resource type="Environment" id=11] background_mode = 2 -background_sky = SubResource( 7 ) +background_sky = SubResource( 10 ) -[sub_resource type="Shader" id=9] +[sub_resource type="Shader" id=12] code = "shader_type canvas_item; uniform sampler2D tex; @@ -97,8 +36,8 @@ void fragment() { COLOR = texture(tex, UV); }" -[sub_resource type="ShaderMaterial" id=10] -shader = SubResource( 9 ) +[sub_resource type="ShaderMaterial" id=13] +shader = SubResource( 12 ) [node name="Preview" type="ViewportContainer"] anchor_left = 1.0 @@ -126,22 +65,8 @@ handle_input_locally = false render_target_clear_mode = 1 render_target_update_mode = 3 -[node name="Objects" type="Spatial" parent="MaterialPreview"] -transform = Transform( -0.482492, 0, 0.875895, 0, 1, 0, -0.875895, 0, -0.482492, 0, 0, 0 ) - -[node name="Cube" type="MeshInstance" parent="MaterialPreview/Objects"] -mesh = SubResource( 2 ) -material/0 = SubResource( 3 ) - -[node name="Cylinder" type="MeshInstance" parent="MaterialPreview/Objects"] -visible = false -mesh = SubResource( 4 ) -material/0 = SubResource( 3 ) - -[node name="Sphere" type="MeshInstance" parent="MaterialPreview/Objects"] -visible = false -mesh = SubResource( 5 ) -material/0 = SubResource( 6 ) +[node name="Objects" parent="MaterialPreview" instance=ExtResource( 2 )] +transform = Transform( 0.81104, 0, 0.584983, 0, 1, 0, -0.584983, 0, 0.81104, 0, 0, 0 ) [node name="OmniLight" type="OmniLight" parent="MaterialPreview"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1.04729, 1.80471, -2.51024 ) @@ -149,11 +74,11 @@ omni_range = 6.46518 [node name="Camera" type="Camera" parent="MaterialPreview"] transform = Transform( 1, 0, 0, 0, 0.766044, 0.642787, 0, -0.642787, 0.766044, 0, 1.83022, 2.2549 ) -environment = SubResource( 8 ) +environment = SubResource( 11 ) current = true [node name="WorldEnvironment" type="WorldEnvironment" parent="MaterialPreview"] -environment = SubResource( 8 ) +environment = SubResource( 11 ) [node name="Config" type="HBoxContainer" parent="."] anchor_right = 1.0 @@ -164,7 +89,7 @@ margin_right = 100.0 margin_bottom = 20.0 rect_min_size = Vector2( 100, 0 ) text = "Cube" -items = [ "Cube", null, false, 0, null, "Cylinder", null, false, 1, null, "Sphere", null, false, 2, null ] +items = [ "Cube", null, false, -1, null, "Cylinder", null, false, -1, null, "Sphere", null, false, -1, null, "Plane", null, false, -1, null ] selected = 0 [node name="Environment" type="OptionButton" parent="Config"] @@ -177,7 +102,7 @@ items = [ "Experiment", null, false, 0, null, "Lobby", null, false, 1, null, "Ni selected = 3 [node name="Preview2D" type="ColorRect" parent="."] -material = SubResource( 10 ) +material = SubResource( 13 ) anchor_top = 1.0 anchor_bottom = 1.0 margin_top = -64.0 diff --git a/addons/material_maker/preview_objects.tscn b/addons/material_maker/preview_objects.tscn new file mode 100644 index 0000000..0fb657f --- /dev/null +++ b/addons/material_maker/preview_objects.tscn @@ -0,0 +1,65 @@ +[gd_scene load_steps=12 format=2] + +[ext_resource path="res://rodz_labs_logo.png" type="Texture" id=1] + +[sub_resource type="CubeMesh" id=1] + +[sub_resource type="SpatialMaterial" id=2] +albedo_texture = ExtResource( 1 ) +uv1_scale = Vector3( 3, 2, 1 ) + +[sub_resource type="CylinderMesh" id=3] + +[sub_resource type="SpatialMaterial" id=4] +albedo_texture = ExtResource( 1 ) +uv1_scale = Vector3( 2, 2, 2 ) + +[sub_resource type="SphereMesh" id=5] +radius = 1.5 +height = 3.0 + +[sub_resource type="SpatialMaterial" id=6] +albedo_texture = ExtResource( 1 ) +uv1_scale = Vector3( 2, 2, 2 ) +uv1_offset = Vector3( 0, 0.5, 0 ) + +[sub_resource type="PlaneMesh" id=7] +size = Vector2( 3, 3 ) + +[sub_resource type="SpatialMaterial" id=8] +albedo_texture = ExtResource( 1 ) + +[sub_resource type="PlaneMesh" id=9] +size = Vector2( 12, 12 ) + +[sub_resource type="SpatialMaterial" id=10] +albedo_texture = ExtResource( 1 ) +uv1_scale = Vector3( 4, 4, 4 ) + +[node name="Objects" type="Spatial"] +transform = Transform( -0.685898, 0, 0.727691, 0, 1, 0, -0.727691, 0, -0.685898, 0, 0, 0 ) + +[node name="Cube" type="MeshInstance" parent="."] +visible = false +mesh = SubResource( 1 ) +material/0 = SubResource( 2 ) + +[node name="Cylinder" type="MeshInstance" parent="."] +visible = false +mesh = SubResource( 3 ) +material/0 = SubResource( 4 ) + +[node name="Sphere" type="MeshInstance" parent="."] +visible = false +mesh = SubResource( 5 ) +material/0 = SubResource( 6 ) + +[node name="Quad" type="MeshInstance" parent="."] +visible = false +mesh = SubResource( 7 ) +material/0 = SubResource( 8 ) + +[node name="Plane" type="MeshInstance" parent="."] +visible = false +mesh = SubResource( 9 ) +material/0 = SubResource( 10 ) diff --git a/rodz_labs_logo.png b/rodz_labs_logo.png index dd7e4d3..8914028 100644 Binary files a/rodz_labs_logo.png and b/rodz_labs_logo.png differ