From f1ff09dcc4894a68fa0ad1319eede394f9eeb847 Mon Sep 17 00:00:00 2001 From: RodZill4 Date: Tue, 28 Jan 2020 11:47:29 +0100 Subject: [PATCH] Moved MMLoader to autoload. Updated demo so it can be exported. --- addons/material_maker/engine/gen_base.gd | 85 +++++++++++++++++-- addons/material_maker/engine/gen_graph.gd | 2 +- addons/material_maker/engine/loader.gd | 16 ++-- addons/material_maker/engine/renderer.gd | 69 --------------- .../import_plugin/ptex_spatial_material.gd | 3 +- addons/material_maker/plugin.gd | 2 +- demo/demo.tscn | 81 +++++++++--------- demo/object.tscn | 49 +++++++++++ export_presets.cfg | 48 ++++++++++- material_maker/examples/beehive.ptex.import | 2 +- material_maker/examples/bricks.ptex.import | 2 +- material_maker/examples/floor1.ptex.import | 2 +- material_maker/examples/marble.ptex.import | 2 +- .../examples/medieval_wall.ptex.import | 2 +- material_maker/graph_edit.gd | 7 +- material_maker/main_window.gd | 4 +- material_maker/nodes/debug.gd | 4 +- material_maker/nodes/generic.gd | 4 +- project.godot | 9 +- start.gd | 11 +++ start.tscn | 11 +++ 21 files changed, 265 insertions(+), 150 deletions(-) create mode 100644 demo/object.tscn create mode 100644 start.gd create mode 100644 start.tscn diff --git a/addons/material_maker/engine/gen_base.gd b/addons/material_maker/engine/gen_base.gd index acc3eab..73cadbc 100644 --- a/addons/material_maker/engine/gen_base.gd +++ b/addons/material_maker/engine/gen_base.gd @@ -40,11 +40,11 @@ var seed_value : int = 0 const PORT_TYPE_NAMES : Array = [ "f", "rgb", "rgba", "sdf2d", "sdf3d" ] const PORT_TYPES : Dictionary = { - f = { type="float", paramdefs="vec2 uv", params="uv", slot_type=0, color=Color(0.5, 0.5, 0.5) }, - rgb = { type="vec3", paramdefs="vec2 uv", params="uv", slot_type=0, color=Color(0.5, 0.5, 1.0) }, - rgba = { type="vec4", paramdefs="vec2 uv", params="uv", slot_type=0, color=Color(0.0, 0.5, 0.0, 0.5) }, - sdf2d = { type="float", paramdefs="vec2 uv", params="uv", slot_type=1, color=Color(1.0, 0.5, 0.0) }, - sdf3d = { type="float", paramdefs="vec3 p", params="p", slot_type=2, color=Color(1.0, 0.0, 0.0) }, + f = { label="Greyscale", type="float", paramdefs="vec2 uv", params="uv", slot_type=0, color=Color(0.5, 0.5, 0.5) }, + rgb = { label="Color", type="vec3", paramdefs="vec2 uv", params="uv", slot_type=0, color=Color(0.5, 0.5, 1.0) }, + rgba = { label="RGBA", type="vec4", paramdefs="vec2 uv", params="uv", slot_type=0, color=Color(0.0, 0.5, 0.0, 0.5) }, + sdf2d = { label="SDF2D", type="float", paramdefs="vec2 uv", params="uv", slot_type=1, color=Color(1.0, 0.5, 0.0) }, + sdf3d = { label="SDF3D", type="float", paramdefs="vec3 p", params="p", slot_type=2, color=Color(1.0, 0.0, 0.0) }, any = { slot_type=42, color=Color(1.0, 1.0, 1.0) } } @@ -165,6 +165,75 @@ func get_input_shader(input_index : int) -> Dictionary: func get_shader(output_index : int, context) -> Dictionary: return get_shader_code("UV", output_index, context) +func generate_preview_shader(src_code) -> String: + var code + code = "shader_type canvas_item;\n" + code += "render_mode blend_disabled;\n" + code += "uniform float preview_size = 64;\n" + var file = File.new() + file.open("res://addons/material_maker/common.shader", File.READ) + code += file.get_as_text() + code += "\n" + if src_code.has("textures"): + for t in src_code.textures.keys(): + code += "uniform sampler2D "+t+";\n" + if src_code.has("globals"): + for g in src_code.globals: + code += g + var shader_code = src_code.defs + if src_code.has("rgba"): + shader_code += "\nvoid fragment() {\n" + shader_code += "vec2 uv = UV;\n" + shader_code += src_code.code + shader_code += "COLOR = "+src_code.rgba+";\n" + shader_code += "}\n" + elif src_code.has("sdf2d"): + shader_code += "\nvoid fragment() {\n" + shader_code += "vec2 uv = UV;\n" + shader_code += src_code.code + shader_code += "float d = "+src_code.sdf2d+";\n" + shader_code += "vec3 col = vec3(cos(d*min(256, preview_size)));\n" + shader_code += "col *= clamp(1.0-d*d, 0.0, 1.0);\n" + shader_code += "col *= vec3(1.0, vec2(step(-0.015, d)));\n" + shader_code += "col *= vec3(vec2(step(d, 0.015)), 1.0);\n" + shader_code += "COLOR = vec4(col, 1.0);\n" + shader_code += "}\n" + elif src_code.has("sdf3d"): + shader_code += "\nfloat calcdist(vec3 uv) {\n" + shader_code += src_code.code + shader_code += "return min("+src_code.sdf3d+", uv.z);\n" + shader_code += "}\n" + shader_code += "float raymarch(vec3 ro, vec3 rd) {\n" + shader_code += "float d=0.0;\n" + shader_code += "for (int i = 0; i < 50; i++) {\n" + shader_code += "vec3 p = ro + rd*d;\n" + shader_code += "float dstep = calcdist(p);\n" + shader_code += "d += dstep;\n" + shader_code += "if (dstep < 0.0001) break;\n" + shader_code += "}\n" + shader_code += "return d;\n" + shader_code += "}\n" + shader_code += "vec3 normal(vec3 p) {\n" + shader_code += " float d = calcdist(p);\n" + shader_code += " float e = .0001;\n" + shader_code += " vec3 n = d - vec3(calcdist(p-vec3(e, 0.0, 0.0)), calcdist(p-vec3(0.0, e, 0.0)), calcdist(p-vec3(0.0, 0.0, e)));\n" + shader_code += " return normalize(n);\n" + shader_code += "}\n" + shader_code += "\nvoid fragment() {\n" + shader_code += "vec2 uv = UV-vec2(0.5);\n" + shader_code += "vec3 p = vec3(uv, 2.0-raymarch(vec3(uv, 2.0), vec3(0.0, 0.0, -1.0)));\n" + shader_code += "vec3 n = normal(p);\n" + shader_code += "vec3 l = vec3(5.0, 5.0, 10.0);\n" + shader_code += "vec3 ld = normalize(l-p);\n" + shader_code += "float o = step(p.z, 0.001);\n" + shader_code += "float shadow = 1.0-0.75*step(raymarch(l, -ld), length(l-p)-0.01);\n" + shader_code += "float light = 0.3+0.7*dot(n, ld)*shadow;\n" + shader_code += "COLOR = vec4(vec3(0.8+0.2*o, 0.8+0.2*o, 1.0)*light, 1.0);\n" + shader_code += "}\n" + #print("GENERATED SHADER:\n"+shader_code) + code += shader_code + return code + func render(output_index : int, size : int, preview : bool = false) -> Object: var context : MMGenContext = MMGenContext.new() var source = get_shader_code("uv", output_index, context) @@ -174,7 +243,11 @@ func render(output_index : int, size : int, preview : bool = false) -> Object: source = { defs="", code="", textures={}, rgba="vec4(0.0)" } var shader : String if preview: - shader = mm_renderer.generate_preview_shader(source) + var outputs = get_output_defs() + if outputs.size() > output_index: + var output = outputs[output_index] + print(output) + shader = generate_preview_shader(source) else: shader = mm_renderer.generate_shader(source) var result = mm_renderer.render_shader(shader, source.textures, size) diff --git a/addons/material_maker/engine/gen_graph.gd b/addons/material_maker/engine/gen_graph.gd index 078d8eb..0fd6576 100644 --- a/addons/material_maker/engine/gen_graph.gd +++ b/addons/material_maker/engine/gen_graph.gd @@ -332,4 +332,4 @@ func _deserialize(data : Dictionary) -> void: label = data.label var nodes = data.nodes if data.has("nodes") else [] var connections = data.connections if data.has("connections") else [] - load("res://addons/material_maker/engine/loader.gd").add_to_gen_graph(self, nodes, connections) + mm_loader.add_to_gen_graph(self, nodes, connections) diff --git a/addons/material_maker/engine/loader.gd b/addons/material_maker/engine/loader.gd index f974215..c4cfd41 100644 --- a/addons/material_maker/engine/loader.gd +++ b/addons/material_maker/engine/loader.gd @@ -1,23 +1,25 @@ tool -extends Object -class_name MMGenLoader +extends Node const STD_GENDEF_PATH = "res://addons/material_maker/nodes" -static func generator_name_from_path(path : String) -> String: +func _ready(): + print("loader ready!") + +func generator_name_from_path(path : String) -> String: for p in [ STD_GENDEF_PATH, OS.get_executable_path().get_base_dir()+"/generators" ]: print(p) print(path.get_base_dir()) return path.get_basename().get_file() -static func load_gen(filename: String) -> MMGenBase: +func load_gen(filename: String) -> MMGenBase: var file = File.new() if file.open(filename, File.READ) == OK: var data = parse_json(file.get_as_text()) return create_gen(data) return null -static func add_to_gen_graph(gen_graph, generators, connections) -> Dictionary: +func add_to_gen_graph(gen_graph, generators, connections) -> Dictionary: var rv = { generators=[], connections=[] } var gennames = {} for n in generators: @@ -35,7 +37,7 @@ static func add_to_gen_graph(gen_graph, generators, connections) -> Dictionary: rv.connections.append(c) return rv -static func create_gen(data) -> MMGenBase: +func create_gen(data) -> MMGenBase: var guess = [ { keyword="connections", type=MMGenGraph }, { keyword="nodes", type=MMGenGraph }, @@ -88,7 +90,7 @@ static func create_gen(data) -> MMGenBase: generator.deserialize(data) return generator -static func get_generator_list() -> Array: +func get_generator_list() -> Array: var rv = [] var dir : Directory = Directory.new() for p in [ STD_GENDEF_PATH, OS.get_executable_path().get_base_dir()+"/generators" ]: diff --git a/addons/material_maker/engine/renderer.gd b/addons/material_maker/engine/renderer.gd index 94e0fd6..70c2980 100644 --- a/addons/material_maker/engine/renderer.gd +++ b/addons/material_maker/engine/renderer.gd @@ -38,75 +38,6 @@ static func generate_shader(src_code) -> String: code += shader_code return code -static func generate_preview_shader(src_code) -> String: - var code - code = "shader_type canvas_item;\n" - code += "render_mode blend_disabled;\n" - code += "uniform float preview_size = 64;\n" - var file = File.new() - file.open("res://addons/material_maker/common.shader", File.READ) - code += file.get_as_text() - code += "\n" - if src_code.has("textures"): - for t in src_code.textures.keys(): - code += "uniform sampler2D "+t+";\n" - if src_code.has("globals"): - for g in src_code.globals: - code += g - var shader_code = src_code.defs - if src_code.has("rgba"): - shader_code += "\nvoid fragment() {\n" - shader_code += "vec2 uv = UV;\n" - shader_code += src_code.code - shader_code += "COLOR = "+src_code.rgba+";\n" - shader_code += "}\n" - elif src_code.has("sdf2d"): - shader_code += "\nvoid fragment() {\n" - shader_code += "vec2 uv = UV;\n" - shader_code += src_code.code - shader_code += "float d = "+src_code.sdf2d+";\n" - shader_code += "vec3 col = vec3(cos(d*min(256, preview_size)));\n" - shader_code += "col *= clamp(1.0-d*d, 0.0, 1.0);\n" - shader_code += "col *= vec3(1.0, vec2(step(-0.015, d)));\n" - shader_code += "col *= vec3(vec2(step(d, 0.015)), 1.0);\n" - shader_code += "COLOR = vec4(col, 1.0);\n" - shader_code += "}\n" - elif src_code.has("sdf3d"): - shader_code += "\nfloat calcdist(vec3 uv) {\n" - shader_code += src_code.code - shader_code += "return min("+src_code.sdf3d+", uv.z);\n" - shader_code += "}\n" - shader_code += "float raymarch(vec3 ro, vec3 rd) {\n" - shader_code += "float d=0.0;\n" - shader_code += "for (int i = 0; i < 50; i++) {\n" - shader_code += "vec3 p = ro + rd*d;\n" - shader_code += "float dstep = calcdist(p);\n" - shader_code += "d += dstep;\n" - shader_code += "if (dstep < 0.0001) break;\n" - shader_code += "}\n" - shader_code += "return d;\n" - shader_code += "}\n" - shader_code += "vec3 normal(vec3 p) {\n" - shader_code += " float d = calcdist(p);\n" - shader_code += " float e = .0001;\n" - shader_code += " vec3 n = d - vec3(calcdist(p-vec3(e, 0.0, 0.0)), calcdist(p-vec3(0.0, e, 0.0)), calcdist(p-vec3(0.0, 0.0, e)));\n" - shader_code += " return normalize(n);\n" - shader_code += "}\n" - shader_code += "\nvoid fragment() {\n" - shader_code += "vec2 uv = UV-vec2(0.5);\n" - shader_code += "vec3 p = vec3(uv, 2.0-raymarch(vec3(uv, 2.0), vec3(0.0, 0.0, -1.0)));\n" - shader_code += "vec3 n = normal(p);\n" - shader_code += "vec3 l = vec3(5.0, 5.0, 10.0);\n" - shader_code += "vec3 ld = normalize(l-p);\n" - shader_code += "float o = step(p.z, 0.001);\n" - shader_code += "float shadow = 1.0-0.75*step(raymarch(l, -ld), length(l-p)-0.01);\n" - shader_code += "float light = 0.3+0.7*dot(n, ld)*shadow;\n" - shader_code += "COLOR = vec4(vec3(0.8+0.2*o, 0.8+0.2*o, 1.0)*light, 1.0);\n" - shader_code += "}\n" - #print("GENERATED SHADER:\n"+shader_code) - code += shader_code - return code - static func generate_combined_shader(red_code, green_code, blue_code) -> String: var code code = "shader_type canvas_item;\n" diff --git a/addons/material_maker/import_plugin/ptex_spatial_material.gd b/addons/material_maker/import_plugin/ptex_spatial_material.gd index c347e00..b9310a5 100644 --- a/addons/material_maker/import_plugin/ptex_spatial_material.gd +++ b/addons/material_maker/import_plugin/ptex_spatial_material.gd @@ -13,8 +13,7 @@ func set_ptex(s : String) -> void : call_deferred("update_texture") func update_texture() -> void: - var loader = MMGenLoader.new() - var mm_graph = loader.create_gen(parse_json(ptex)) + var mm_graph = mm_loader.create_gen(parse_json(ptex)) if mm_graph == null: return var mm_material : MMGenMaterial = mm_graph.get_node("Material") diff --git a/addons/material_maker/plugin.gd b/addons/material_maker/plugin.gd index 67eaec6..b6b6011 100644 --- a/addons/material_maker/plugin.gd +++ b/addons/material_maker/plugin.gd @@ -13,7 +13,7 @@ func _exit_tree() -> void: importer = null func generate_material(ptex_filename: String) -> Material: - var generator = MMGenLoader.load_gen(ptex_filename) + var generator = mm_loader.load_gen(ptex_filename) add_child(generator) if generator.has_node("Material"): var gen_material = generator.get_node("Material") diff --git a/demo/demo.tscn b/demo/demo.tscn index 524bc97..adebca3 100644 --- a/demo/demo.tscn +++ b/demo/demo.tscn @@ -1,13 +1,16 @@ -[gd_scene load_steps=8 format=2] +[gd_scene load_steps=10 format=2] -[ext_resource path="res://material_maker/examples/skulls.ptex" type="Material" id=1] +[ext_resource path="res://material_maker/examples/bricks.ptex" type="Material" id=1] [ext_resource path="res://material_maker/preview/panoramas/studio_sky.tres" type="Environment" id=2] +[ext_resource path="res://demo/object.tscn" type="PackedScene" id=3] +[ext_resource path="res://material_maker/examples/marble.ptex" type="Material" id=4] +[ext_resource path="res://material_maker/examples/medieval_wall.ptex" type="Material" id=5] +[ext_resource path="res://material_maker/examples/floor1.ptex" type="Material" id=6] +[ext_resource path="res://material_maker/examples/beehive.ptex" type="Material" id=7] -[sub_resource type="SphereMesh" id=1] - -[sub_resource type="Animation" id=2] +[sub_resource type="Animation" id=1] resource_name = "rotate" -length = 10.0 +length = 5.0 loop = true tracks/0/type = "value" tracks/0/path = NodePath("CamPivot:rotation_degrees") @@ -16,68 +19,66 @@ tracks/0/loop_wrap = true tracks/0/imported = false tracks/0/enabled = true tracks/0/keys = { -"times": PoolRealArray( 0, 10 ), +"times": PoolRealArray( 0, 5 ), "transitions": PoolRealArray( 1, 1 ), "update": 0, "values": [ Vector3( 0, 0, 0 ), Vector3( 0, 360, 0 ) ] } -[sub_resource type="SpatialMaterial" id=4] -flags_unshaded = true -flags_do_not_receive_shadows = true - -[sub_resource type="SphereMesh" id=5] -material = SubResource( 4 ) -radius = 0.1 -height = 0.2 - -[sub_resource type="Animation" id=3] -resource_name = "rotate" -length = 5.0 +[sub_resource type="Animation" id=2] +resource_name = "move" +length = 50.0 loop = true tracks/0/type = "value" -tracks/0/path = NodePath("LightPivot:rotation_degrees") +tracks/0/path = NodePath("CamPivot:translation") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/imported = false tracks/0/enabled = true tracks/0/keys = { -"times": PoolRealArray( 0, 5 ), -"transitions": PoolRealArray( 1, 1 ), +"times": PoolRealArray( 0, 4, 5, 9, 10, 14, 15, 19, 20, 24, 25, 29, 30, 34, 35, 39, 40, 44, 45, 49 ), +"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), "update": 0, -"values": [ Vector3( 0, 0, 0 ), Vector3( 360, 0, 0 ) ] +"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 0, 0 ), Vector3( 0, 0, -5 ), Vector3( 0, 0, -5 ), Vector3( 0, 0, -10 ), Vector3( 0, 0, -10 ), Vector3( 0, 0, -15 ), Vector3( 0, 0, -15 ), Vector3( 0, 0, -20 ), Vector3( 0, 0, -20 ), Vector3( 0, 0, -25 ), Vector3( 0, 0, -25 ), Vector3( 0, 0, -20 ), Vector3( 0, 0, -20 ), Vector3( 0, 0, -15 ), Vector3( 0, 0, -15 ), Vector3( 0, 0, -10 ), Vector3( 0, 0, -10 ), Vector3( 0, 0, -5 ), Vector3( 0, 0, -5 ) ] } [node name="Spatial" type="Spatial"] -[node name="MeshInstance" type="MeshInstance" parent="."] -mesh = SubResource( 1 ) -material/0 = ExtResource( 1 ) - [node name="CamPivot" type="Spatial" parent="."] -transform = Transform( 0.982287, 0, 0.187381, 0, 1, 0, -0.187381, 0, 0.982287, 0, 0, 0 ) +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5 ) [node name="Camera" type="Camera" parent="CamPivot"] transform = Transform( 0.999487, 0.0319038, 0.00268748, -0.0319038, 0.985399, 0.167245, 0.00268751, -0.167245, 0.985912, 0.28563, 0.826821, 2.79088 ) [node name="CamRotate" type="AnimationPlayer" parent="."] autoplay = "rotate" -anims/rotate = SubResource( 2 ) +anims/rotate = SubResource( 1 ) -[node name="LightPivot" type="Spatial" parent="."] -transform = Transform( 1, 0, 0, 0, 0.929776, -0.368125, 0, 0.368125, 0.929776, 0, 0, 0 ) +[node name="CamMove" type="AnimationPlayer" parent="."] +autoplay = "move" +anims/move = SubResource( 2 ) -[node name="OmniLight" type="OmniLight" parent="LightPivot"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0746527, 1.74306, 0 ) +[node name="Skulls" parent="." instance=ExtResource( 3 )] -[node name="MeshInstance" type="MeshInstance" parent="LightPivot/OmniLight"] -cast_shadow = 0 -mesh = SubResource( 5 ) -material/0 = null +[node name="Bricks" parent="." instance=ExtResource( 3 )] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5 ) +material/0 = ExtResource( 1 ) -[node name="LightRotate" type="AnimationPlayer" parent="."] -autoplay = "rotate" -anims/rotate = SubResource( 3 ) +[node name="Floor" parent="." instance=ExtResource( 3 )] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -10 ) +material/0 = ExtResource( 6 ) + +[node name="Marble" parent="." instance=ExtResource( 3 )] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -15 ) +material/0 = ExtResource( 4 ) + +[node name="MedievalWall" parent="." instance=ExtResource( 3 )] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -20 ) +material/0 = ExtResource( 5 ) + +[node name="BeeHive" parent="." instance=ExtResource( 3 )] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -25 ) +material/0 = ExtResource( 7 ) [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = ExtResource( 2 ) diff --git a/demo/object.tscn b/demo/object.tscn new file mode 100644 index 0000000..ac597a8 --- /dev/null +++ b/demo/object.tscn @@ -0,0 +1,49 @@ +[gd_scene load_steps=6 format=2] + +[ext_resource path="res://material_maker/examples/skulls.ptex" type="Material" id=1] + +[sub_resource type="SphereMesh" id=1] + +[sub_resource type="SpatialMaterial" id=2] +flags_unshaded = true +flags_do_not_receive_shadows = true + +[sub_resource type="SphereMesh" id=3] +material = SubResource( 2 ) +radius = 0.1 +height = 0.2 + +[sub_resource type="Animation" id=4] +length = 5.0 +loop = true +tracks/0/type = "value" +tracks/0/path = NodePath("LightPivot:rotation_degrees") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 5 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector3( 0, 0, 0 ), Vector3( 360, 0, 0 ) ] +} + +[node name="MeshInstance" type="MeshInstance"] +mesh = SubResource( 1 ) +material/0 = ExtResource( 1 ) + +[node name="LightPivot" type="Spatial" parent="."] +transform = Transform( 1, 0, 0, 0, 0.929776, -0.368125, 0, 0.368125, 0.929776, 0, 0, 0 ) + +[node name="OmniLight" type="OmniLight" parent="LightPivot"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0746527, 1.74306, 0 ) + +[node name="MeshInstance" type="MeshInstance" parent="LightPivot/OmniLight"] +cast_shadow = 0 +mesh = SubResource( 3 ) +material/0 = null + +[node name="LightRotate" type="AnimationPlayer" parent="."] +autoplay = "rotate" +anims/rotate = SubResource( 4 ) diff --git a/export_presets.cfg b/export_presets.cfg index 88aa5cf..262454f 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -1,8 +1,8 @@ [preset.0] -name="Windows Desktop" +name="Windows" platform="Windows Desktop" -runnable=true +runnable=false custom_features="" export_filter="resources" export_files=PoolStringArray( "res://addons/material_maker/common.shader", "res://addons/material_maker/engine/gen_base.gd", "res://addons/material_maker/engine/gen_buffer.gd", "res://addons/material_maker/engine/gen_comment.gd", "res://addons/material_maker/engine/gen_context.gd", "res://addons/material_maker/engine/gen_convolution.gd", "res://addons/material_maker/engine/gen_debug.gd", "res://addons/material_maker/engine/gen_export.gd", "res://addons/material_maker/engine/gen_graph.gd", "res://addons/material_maker/engine/gen_image.gd", "res://addons/material_maker/engine/gen_ios.gd", "res://addons/material_maker/engine/gen_material.gd", "res://addons/material_maker/engine/gen_remote.gd", "res://addons/material_maker/engine/gen_shader.gd", "res://addons/material_maker/engine/gen_switch.gd", "res://addons/material_maker/engine/gen_texture.gd", "res://addons/material_maker/engine/loader.gd", "res://addons/material_maker/engine/renderer.gd", "res://addons/material_maker/engine/renderer.tscn", "res://addons/material_maker/types/gradient.gd", "res://addons/material_maker/types/types.gd", "res://default_env.tres", "res://icon.png", "res://material_maker/environment.gd", "res://material_maker/fonts/hack.ttf", "res://material_maker/graph_edit.gd", "res://material_maker/graph_edit.tscn", "res://material_maker/icons/icon.png", "res://material_maker/icons/icons.svg", "res://material_maker/icons/link.tres", "res://material_maker/icons/randomness_locked.tres", "res://material_maker/icons/randomness_unlocked.tres", "res://material_maker/icons/remove.tres", "res://material_maker/library.gd", "res://material_maker/library.tscn", "res://material_maker/library_tree.gd", "res://material_maker/main_window.gd", "res://material_maker/main_window.tscn", "res://material_maker/node_factory.gd", "res://material_maker/nodes/base.gd", "res://material_maker/nodes/comment.gd", "res://material_maker/nodes/comment.tscn", "res://material_maker/nodes/debug.gd", "res://material_maker/nodes/debug.tscn", "res://material_maker/nodes/debug/debug_popup.gd", "res://material_maker/nodes/debug/debug_popup.tscn", "res://material_maker/nodes/edit_buttons.gd", "res://material_maker/nodes/edit_buttons.tscn", "res://material_maker/nodes/generic.gd", "res://material_maker/nodes/generic.tscn", "res://material_maker/nodes/image.gd", "res://material_maker/nodes/image.tscn", "res://material_maker/nodes/image/godot_logo.png", "res://material_maker/nodes/ios.gd", "res://material_maker/nodes/ios.tscn", "res://material_maker/nodes/ios/add.tscn", "res://material_maker/nodes/ios/port.gd", "res://material_maker/nodes/ios/port.tscn", "res://material_maker/nodes/remote.gd", "res://material_maker/nodes/remote.tscn", "res://material_maker/nodes/switch.gd", "res://material_maker/nodes/switch.tscn", "res://material_maker/preview/control_point.gd", "res://material_maker/preview/control_point.tscn", "res://material_maker/preview/panoramas/epping_forest_01.hdr", "res://material_maker/preview/panoramas/moonless_golf.hdr", "res://material_maker/preview/panoramas/studio_sky.tres", "res://material_maker/preview/preview_2d.gd", "res://material_maker/preview/preview_2d.tscn", "res://material_maker/preview/preview_3d.gd", "res://material_maker/preview/preview_3d.tscn", "res://material_maker/preview/preview_3d_scene.tscn", "res://material_maker/preview/preview_3d_ui.gd", "res://material_maker/preview/preview_3d_ui.tscn", "res://material_maker/preview/preview_light.gd", "res://material_maker/preview/preview_light.tscn", "res://material_maker/preview/preview_objects.tscn", "res://material_maker/widgets/about/about.gd", "res://material_maker/widgets/about/about.tscn", "res://material_maker/widgets/about/facebook.png", "res://material_maker/widgets/about/github.png", "res://material_maker/widgets/about/itchio.png", "res://material_maker/widgets/about/twitter.png", "res://material_maker/widgets/about/youtube.png", "res://material_maker/widgets/float_edit.gd", "res://material_maker/widgets/float_edit.tscn", "res://material_maker/widgets/gradient_editor.gd", "res://material_maker/widgets/gradient_editor.tscn", "res://material_maker/widgets/gradient_popup.gd", "res://material_maker/widgets/gradient_popup.tscn", "res://material_maker/widgets/graph_tree/graph_tree.gd", "res://material_maker/widgets/graph_tree/graph_tree.tscn", "res://material_maker/widgets/hslider.gd", "res://material_maker/widgets/hslider.tscn", "res://material_maker/widgets/icon.png", "res://material_maker/widgets/line_dialog.gd", "res://material_maker/widgets/line_dialog.tscn", "res://material_maker/widgets/linked_widgets/editable_label.gd", "res://material_maker/widgets/linked_widgets/editable_label.tscn", "res://material_maker/widgets/linked_widgets/link.gd", "res://material_maker/widgets/node_editor.tscn", "res://material_maker/widgets/node_editor/enum_editor.gd", "res://material_maker/widgets/node_editor/enum_editor.tscn", "res://material_maker/widgets/node_editor/input.gd", "res://material_maker/widgets/node_editor/input.tscn", "res://material_maker/widgets/node_editor/node_editor.gd", "res://material_maker/widgets/node_editor/node_editor.tscn", "res://material_maker/widgets/node_editor/node_editor_item_list.gd", "res://material_maker/widgets/node_editor/output.gd", "res://material_maker/widgets/node_editor/output.tscn", "res://material_maker/widgets/node_editor/parameter.gd", "res://material_maker/widgets/node_editor/parameter.tscn", "res://material_maker/widgets/node_editor/parameter_boolean.gd", "res://material_maker/widgets/node_editor/parameter_boolean.tscn", "res://material_maker/widgets/node_editor/parameter_color.gd", "res://material_maker/widgets/node_editor/parameter_color.tscn", "res://material_maker/widgets/node_editor/parameter_enum.gd", "res://material_maker/widgets/node_editor/parameter_enum.tscn", "res://material_maker/widgets/node_editor/parameter_float.gd", "res://material_maker/widgets/node_editor/parameter_float.tscn", "res://material_maker/widgets/node_editor/parameter_gradient.gd", "res://material_maker/widgets/node_editor/parameter_gradient.tscn", "res://material_maker/widgets/node_editor/parameter_size.gd", "res://material_maker/widgets/node_editor/parameter_size.tscn", "res://material_maker/widgets/preview_button.tscn", "res://material_maker/widgets/size_option_button.gd", "res://material_maker/widgets/tabs.gd", "res://material_maker/widgets/text_dialog.gd", "res://material_maker/widgets/text_dialog.tscn", "res://material_maker/window_dialog.tscn", "res://rodz_labs_logo.png" ) @@ -126,3 +126,47 @@ html/custom_html_shell="" html/head_include="" custom_template/release="" custom_template/debug="" + +[preset.4] + +name="Windows Demo" +platform="Windows Desktop" +runnable=true +custom_features="" +export_filter="resources" +export_files=PoolStringArray( "res://addons/material_maker/common.shader", "res://addons/material_maker/engine/gen_base.gd", "res://addons/material_maker/engine/gen_buffer.gd", "res://addons/material_maker/engine/gen_comment.gd", "res://addons/material_maker/engine/gen_context.gd", "res://addons/material_maker/engine/gen_convolution.gd", "res://addons/material_maker/engine/gen_debug.gd", "res://addons/material_maker/engine/gen_export.gd", "res://addons/material_maker/engine/gen_graph.gd", "res://addons/material_maker/engine/gen_image.gd", "res://addons/material_maker/engine/gen_ios.gd", "res://addons/material_maker/engine/gen_material.gd", "res://addons/material_maker/engine/gen_remote.gd", "res://addons/material_maker/engine/gen_shader.gd", "res://addons/material_maker/engine/gen_switch.gd", "res://addons/material_maker/engine/gen_texture.gd", "res://addons/material_maker/engine/loader.gd", "res://addons/material_maker/engine/renderer.gd", "res://addons/material_maker/engine/renderer.tscn", "res://addons/material_maker/import_plugin/ptex_spatial_material.gd", "res://addons/material_maker/import_plugin/tesselated.shader", "res://addons/material_maker/types/gradient.gd", "res://addons/material_maker/types/types.gd", "res://default_env.tres", "res://demo/demo.tscn", "res://icon.png", "res://rodz_labs_logo.png", "res://start.gd", "res://start.tscn" ) +include_filter="*.mmg,*.json" +exclude_filter="" +export_path="../../Releases/material_maker_demo.exe" +patch_list=PoolStringArray( ) +script_export_mode=1 +script_encryption_key="" + +[preset.4.options] + +texture_format/bptc=false +texture_format/s3tc=true +texture_format/etc=true +texture_format/etc2=true +texture_format/no_bptc_fallbacks=true +binary_format/64_bits=true +binary_format/embed_pck=false +custom_template/release="" +custom_template/debug="" +codesign/enable=false +codesign/identity_type=0 +codesign/identity="" +codesign/password="" +codesign/timestamp=true +codesign/timestamp_server_url="" +codesign/digest_algorithm=1 +codesign/description="" +codesign/custom_options=PoolStringArray( ) +application/icon="res://icon.ico" +application/file_version="0.8" +application/product_version="0.8" +application/company_name="Rodz Labs" +application/product_name="Material Maker" +application/file_description="" +application/copyright="" +application/trademarks="" diff --git a/material_maker/examples/beehive.ptex.import b/material_maker/examples/beehive.ptex.import index 9f04d7b..87348a2 100644 --- a/material_maker/examples/beehive.ptex.import +++ b/material_maker/examples/beehive.ptex.import @@ -12,4 +12,4 @@ dest_files=[ "res://.import/beehive.ptex-51715262d81c1a144e9a7e141a45db7f.tres" [params] render=false -scale=1.0 +scale=3.0 diff --git a/material_maker/examples/bricks.ptex.import b/material_maker/examples/bricks.ptex.import index 91014ce..b0ee3fc 100644 --- a/material_maker/examples/bricks.ptex.import +++ b/material_maker/examples/bricks.ptex.import @@ -12,4 +12,4 @@ dest_files=[ "res://.import/bricks.ptex-8a4a409b5b41c018677a6156ef3f93e5.tres" ] [params] render=false -scale=1.0 +scale=3.0 diff --git a/material_maker/examples/floor1.ptex.import b/material_maker/examples/floor1.ptex.import index f05886b..724f11b 100644 --- a/material_maker/examples/floor1.ptex.import +++ b/material_maker/examples/floor1.ptex.import @@ -12,4 +12,4 @@ dest_files=[ "res://.import/floor1.ptex-fb54baf7242d73ad5e0d97d70fc2ffe8.tres" ] [params] render=false -scale=1.0 +scale=3.0 diff --git a/material_maker/examples/marble.ptex.import b/material_maker/examples/marble.ptex.import index 610c826..728a21d 100644 --- a/material_maker/examples/marble.ptex.import +++ b/material_maker/examples/marble.ptex.import @@ -12,4 +12,4 @@ dest_files=[ "res://.import/marble.ptex-0b7e8ced36657d462bfe938e53d1f73b.tres" ] [params] render=false -scale=1.0 +scale=3.0 diff --git a/material_maker/examples/medieval_wall.ptex.import b/material_maker/examples/medieval_wall.ptex.import index a2050c7..6458ce3 100644 --- a/material_maker/examples/medieval_wall.ptex.import +++ b/material_maker/examples/medieval_wall.ptex.import @@ -12,4 +12,4 @@ dest_files=[ "res://.import/medieval_wall.ptex-28369316aeb5d9dfca15a3cfe9753817. [params] render=false -scale=1.0 +scale=3.0 diff --git a/material_maker/graph_edit.gd b/material_maker/graph_edit.gd index f165d0d..c183c19 100644 --- a/material_maker/graph_edit.gd +++ b/material_maker/graph_edit.gd @@ -169,8 +169,7 @@ func update_graph(generators, connections) -> Array: func new_material() -> void: clear_material() - var loader = MMGenLoader.new() - top_generator = loader.create_gen({nodes=[{name="Material", type="material","parameters":{"size":11}}], connections=[]}) + top_generator = mm_loader.create_gen({nodes=[{name="Material", type="material","parameters":{"size":11}}], connections=[]}) if top_generator != null: add_child(top_generator) move_child(top_generator, 0) @@ -194,7 +193,7 @@ func create_nodes(data, position : Vector2 = Vector2(0, 0)) -> Array: if data.has("type"): data = { nodes=[data], connections=[] } if typeof(data.nodes) == TYPE_ARRAY and typeof(data.connections) == TYPE_ARRAY: - var new_stuff = MMGenLoader.add_to_gen_graph(generator, data.nodes, data.connections) + var new_stuff = mm_loader.add_to_gen_graph(generator, data.nodes, data.connections) for g in new_stuff.generators: g.position += position return update_graph(new_stuff.generators, new_stuff.connections) @@ -205,7 +204,7 @@ func create_gen_from_type(gen_name) -> void: func load_file(filename) -> void: clear_material() - top_generator = MMGenLoader.load_gen(filename) + top_generator = mm_loader.load_gen(filename) if top_generator != null: add_child(top_generator) move_child(top_generator, 0) diff --git a/material_maker/main_window.gd b/material_maker/main_window.gd index 80c0e73..1114a16 100644 --- a/material_maker/main_window.gd +++ b/material_maker/main_window.gd @@ -195,7 +195,7 @@ func add_recent(path) -> void: f.close() func create_menu_create(menu) -> void: - var gens = MMGenLoader.get_generator_list() + var gens = mm_loader.get_generator_list() menu.clear() for i in gens.size(): menu.add_item(gens[i], i) @@ -205,7 +205,7 @@ func create_menu_create(menu) -> void: func _on_Create_id_pressed(id) -> void: var graph_edit : MMGraphEdit = get_current_graph_edit() if graph_edit != null: - var gens = MMGenLoader.get_generator_list() + var gens = mm_loader.get_generator_list() graph_edit.create_gen_from_type(gens[id]) func menu_about_to_show(name, menu) -> void: diff --git a/material_maker/nodes/debug.gd b/material_maker/nodes/debug.gd index e65b54d..4e66d58 100644 --- a/material_maker/nodes/debug.gd +++ b/material_maker/nodes/debug.gd @@ -1,6 +1,6 @@ extends MMGraphNodeBase -static func generate_shader(src_code) -> String: +static func generate_debug_shader(src_code) -> String: var code code = "" var file = File.new() @@ -32,4 +32,4 @@ func _on_Button_pressed() -> void: var source = src.generator.get_shader_code("UV", src.output_index, context) var popup = preload("res://material_maker/nodes/debug/debug_popup.tscn").instance() get_parent().add_child(popup) - popup.show_code(generate_shader(source)) + popup.show_code(generate_debug_shader(source)) diff --git a/material_maker/nodes/generic.gd b/material_maker/nodes/generic.gd index 164c8c7..6d6d2f1 100644 --- a/material_maker/nodes/generic.gd +++ b/material_maker/nodes/generic.gd @@ -320,9 +320,9 @@ func do_load_generator(file_name : String) -> void: new_generator.set_shader_model(parse_json(file.get_as_text())) file.close() else: - new_generator = MMGenLoader.load_gen(file_name) + new_generator = mm_loader.load_gen(file_name) if new_generator != null: - var gen_name = MMGenLoader.generator_name_from_path(file_name) + var gen_name = mm_loader.generator_name_from_path(file_name) if gen_name != "": new_generator.model = gen_name var parent_generator = generator.get_parent() diff --git a/project.godot b/project.godot index a8a601b..c388f7b 100644 --- a/project.godot +++ b/project.godot @@ -64,11 +64,6 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://addons/material_maker/engine/gen_image.gd" }, { -"base": "Object", -"class": "MMGenLoader", -"language": "GDScript", -"path": "res://addons/material_maker/engine/loader.gd" -}, { "base": "MMGenBase", "class": "MMGenMaterial", "language": "GDScript", @@ -156,7 +151,6 @@ _global_script_class_icons={ "MMGenGraph": "", "MMGenIOs": "", "MMGenImage": "", -"MMGenLoader": "", "MMGenMaterial": "", "MMGenRemote": "", "MMGenRenderer": "", @@ -178,7 +172,7 @@ _global_script_class_icons={ config/name="Material Maker" config/description="An open source, extensible procedural material generation tool" -run/main_scene="res://material_maker/main_window.tscn" +run/main_scene="res://start.tscn" config/use_custom_user_dir=true config/custom_user_dir_name="material_maker" boot_splash/image="res://rodz_labs_logo.png" @@ -189,6 +183,7 @@ config/release="0.8" [autoload] +mm_loader="*res://addons/material_maker/engine/loader.gd" mm_renderer="*res://addons/material_maker/engine/renderer.tscn" [debug] diff --git a/start.gd b/start.gd new file mode 100644 index 0000000..c285ddc --- /dev/null +++ b/start.gd @@ -0,0 +1,11 @@ +extends Control + +func _ready(): + print("Loading...") + call_deferred("change_scene") + +func change_scene(): + if Directory.new().file_exists("res://material_maker/main_window.tscn"): + get_tree().change_scene("res://material_maker/main_window.tscn") + else: + get_tree().change_scene("res://demo/demo.tscn") diff --git a/start.tscn b/start.tscn new file mode 100644 index 0000000..2a7cddd --- /dev/null +++ b/start.tscn @@ -0,0 +1,11 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://start.gd" type="Script" id=1] + +[node name="Start" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +}