mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
Refactored basic load and preview functions in graph editor
This commit is contained in:
parent
bcdac09cd7
commit
57c28993db
@ -22,9 +22,15 @@ class OutputPort:
|
|||||||
func to_str():
|
func to_str():
|
||||||
return generator.name+"("+str(output_index)+")"
|
return generator.name+"("+str(output_index)+")"
|
||||||
|
|
||||||
|
var position : Vector2 = Vector2(0, 0)
|
||||||
|
var parameters = {}
|
||||||
|
|
||||||
func get_seed():
|
func get_seed():
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
func get_type():
|
||||||
|
return "generic"
|
||||||
|
|
||||||
func get_source(input_index : int):
|
func get_source(input_index : int):
|
||||||
return get_parent().get_port_source(name, input_index)
|
return get_parent().get_port_source(name, input_index)
|
||||||
|
|
||||||
@ -33,8 +39,8 @@ func get_input_shader(input_index : int):
|
|||||||
if source != null:
|
if source != null:
|
||||||
return source.get_shader()
|
return source.get_shader()
|
||||||
|
|
||||||
func get_shader(output_index : int):
|
func get_shader(output_index : int, context = MMGenContext.new()):
|
||||||
return get_shader_code("UV", output_index);
|
return get_shader_code("UV", output_index, context);
|
||||||
|
|
||||||
# this will need an output index for switch
|
# this will need an output index for switch
|
||||||
func get_globals():
|
func get_globals():
|
||||||
@ -48,9 +54,9 @@ func get_globals():
|
|||||||
list.append(g)
|
list.append(g)
|
||||||
return list
|
return list
|
||||||
|
|
||||||
func get_shader_code(uv, slot = 0):
|
func get_shader_code(uv, slot = 0, context = MMGenContext.new()):
|
||||||
var rv
|
var rv = _get_shader_code(uv, slot, context)
|
||||||
rv = _get_shader_code(uv, slot)
|
if rv != null:
|
||||||
if !rv.has("f"):
|
if !rv.has("f"):
|
||||||
if rv.has("rgb"):
|
if rv.has("rgb"):
|
||||||
rv.f = "(dot("+rv.rgb+", vec3(1.0))/3.0)"
|
rv.f = "(dot("+rv.rgb+", vec3(1.0))/3.0)"
|
||||||
@ -68,5 +74,5 @@ func get_shader_code(uv, slot = 0):
|
|||||||
rv.globals = get_globals()
|
rv.globals = get_globals()
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
func _get_shader_code(uv : String, output_index : int):
|
func _get_shader_code(uv : String, output_index : int, context = MMGenContext.new()):
|
||||||
return null
|
return null
|
||||||
|
17
addons/material_maker/engine/gen_context.gd
Normal file
17
addons/material_maker/engine/gen_context.gd
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
extends Object
|
||||||
|
class_name MMGenContext
|
||||||
|
|
||||||
|
var variants : Dictionary = {}
|
||||||
|
|
||||||
|
func has_variant(generator):
|
||||||
|
return variants.has(generator)
|
||||||
|
|
||||||
|
func get_variant(generator, uv):
|
||||||
|
var rv = -1
|
||||||
|
if variants.has(generator):
|
||||||
|
rv = variants[generator].find(uv)
|
||||||
|
if rv == -1:
|
||||||
|
variants[generator].push(uv)
|
||||||
|
else:
|
||||||
|
variants[generator] = [uv]
|
||||||
|
return rv
|
@ -2,8 +2,6 @@ tool
|
|||||||
extends MMGenBase
|
extends MMGenBase
|
||||||
class_name MMGenMaterial
|
class_name MMGenMaterial
|
||||||
|
|
||||||
var parameters = {}
|
|
||||||
|
|
||||||
var texture_list
|
var texture_list
|
||||||
|
|
||||||
var material : SpatialMaterial
|
var material : SpatialMaterial
|
||||||
@ -27,6 +25,9 @@ const ADDON_TEXTURE_LIST = [
|
|||||||
{ port=6, texture="depth_map" }
|
{ port=6, texture="depth_map" }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
func get_type():
|
||||||
|
return "material"
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
texture_list = TEXTURE_LIST
|
texture_list = TEXTURE_LIST
|
||||||
if Engine.editor_hint:
|
if Engine.editor_hint:
|
||||||
|
@ -3,7 +3,6 @@ extends MMGenBase
|
|||||||
class_name MMGenShader
|
class_name MMGenShader
|
||||||
|
|
||||||
var model_data = null
|
var model_data = null
|
||||||
var parameters = {}
|
|
||||||
var generated_variants = []
|
var generated_variants = []
|
||||||
|
|
||||||
func set_model_data(data: Dictionary):
|
func set_model_data(data: Dictionary):
|
||||||
@ -32,7 +31,7 @@ func find_keyword_call(string, keyword):
|
|||||||
parenthesis_level -= 1
|
parenthesis_level -= 1
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
func replace_input(string, input, type, src, default):
|
func replace_input(string, context, input, type, src, default):
|
||||||
var required_defs = ""
|
var required_defs = ""
|
||||||
var required_code = ""
|
var required_code = ""
|
||||||
while true:
|
while true:
|
||||||
@ -74,7 +73,7 @@ func replace_variable(string, variable, value):
|
|||||||
string = string.right(keyword_size)
|
string = string.right(keyword_size)
|
||||||
return new_string
|
return new_string
|
||||||
|
|
||||||
func subst(string, uv = ""):
|
func subst(string, context, uv = ""):
|
||||||
var required_defs = ""
|
var required_defs = ""
|
||||||
var required_code = ""
|
var required_code = ""
|
||||||
string = replace_variable(string, "name", name)
|
string = replace_variable(string, "name", name)
|
||||||
@ -103,21 +102,23 @@ func subst(string, uv = ""):
|
|||||||
for i in range(model_data.inputs.size()):
|
for i in range(model_data.inputs.size()):
|
||||||
var input = model_data.inputs[i]
|
var input = model_data.inputs[i]
|
||||||
var source = get_source(i)
|
var source = get_source(i)
|
||||||
var result = replace_input(string, input.name, input.type, source, input.default)
|
var result = replace_input(string, context, input.name, input.type, source, input.default)
|
||||||
string = result.string
|
string = result.string
|
||||||
required_defs += result.defs
|
required_defs += result.defs
|
||||||
required_code += result.code
|
required_code += result.code
|
||||||
return { string=string, defs=required_defs, code=required_code }
|
return { string=string, defs=required_defs, code=required_code }
|
||||||
|
|
||||||
func _get_shader_code(uv, slot = 0):
|
func _get_shader_code(uv, slot = 0, context = MMGenContext.new()):
|
||||||
|
if context == null:
|
||||||
|
context = {}
|
||||||
var output_info = [ { field="rgba", type="vec4" }, { field="rgb", type="vec3" }, { field="f", type="float" } ]
|
var output_info = [ { field="rgba", type="vec4" }, { field="rgb", type="vec3" }, { field="f", type="float" } ]
|
||||||
var rv = { defs="", code="" }
|
var rv = { defs="", code="" }
|
||||||
var variant_string = uv+","+str(slot)
|
var variant_string = uv+","+str(slot)
|
||||||
if model_data != null and model_data.has("outputs") and model_data.outputs.size() > slot:
|
if model_data != null and model_data.has("outputs") and model_data.outputs.size() > slot:
|
||||||
var output = model_data.outputs[slot]
|
var output = model_data.outputs[slot]
|
||||||
rv.defs = ""
|
rv.defs = ""
|
||||||
if model_data.has("instance") && generated_variants.empty():
|
if model_data.has("instance") && !context.has_variant(self):
|
||||||
rv.defs += subst(model_data.instance).string
|
rv.defs += subst(model_data.instance, context).string
|
||||||
for p in model_data.parameters:
|
for p in model_data.parameters:
|
||||||
if p.type == "gradient":
|
if p.type == "gradient":
|
||||||
var g = parameters[p.name]
|
var g = parameters[p.name]
|
||||||
@ -125,13 +126,13 @@ func _get_shader_code(uv, slot = 0):
|
|||||||
g = MMGradient.new()
|
g = MMGradient.new()
|
||||||
g.deserialize(parameters[p.name])
|
g.deserialize(parameters[p.name])
|
||||||
rv.defs += g.get_shader(p.name+"_gradient_fct")
|
rv.defs += g.get_shader(p.name+"_gradient_fct")
|
||||||
var variant_index = generated_variants.find(variant_string)
|
var variant_index = context.get_variant(self, variant_string)
|
||||||
if variant_index == -1:
|
if variant_index == -1:
|
||||||
variant_index = generated_variants.size()
|
variant_index = context.get_variant(self, variant_string)
|
||||||
generated_variants.append(variant_string)
|
generated_variants.append(variant_string)
|
||||||
for t in output_info:
|
for t in output_info:
|
||||||
if output.has(t.field):
|
if output.has(t.field):
|
||||||
var subst_output = subst(output[t.field], uv)
|
var subst_output = subst(output[t.field], context, uv)
|
||||||
rv.defs += subst_output.defs
|
rv.defs += subst_output.defs
|
||||||
rv.code += subst_output.code
|
rv.code += subst_output.code
|
||||||
rv.code += "%s %s_%d_%d_%s = %s;\n" % [ t.type, name, slot, variant_index, t.field, subst_output.string ]
|
rv.code += "%s %s_%d_%d_%s = %s;\n" % [ t.type, name, slot, variant_index, t.field, subst_output.string ]
|
||||||
|
@ -18,16 +18,21 @@ func create_gen(data) -> MMGenBase:
|
|||||||
if g != null:
|
if g != null:
|
||||||
generator.add_child(g)
|
generator.add_child(g)
|
||||||
generator.connections = data.connections
|
generator.connections = data.connections
|
||||||
|
elif data.has("model_data"):
|
||||||
|
generator = MMGenShader.new()
|
||||||
|
generator.set_model_data(data.model_data)
|
||||||
elif data.has("type"):
|
elif data.has("type"):
|
||||||
if data.type == "material":
|
if data.type == "material":
|
||||||
generator = MMGenMaterial.new()
|
generator = MMGenMaterial.new()
|
||||||
else:
|
|
||||||
generator = MMGenShader.new()
|
|
||||||
if data.type == "custom":
|
|
||||||
generator.set_model_data(data.model_data)
|
|
||||||
else:
|
else:
|
||||||
var file = File.new()
|
var file = File.new()
|
||||||
if file.open("res://addons/material_maker/nodes/"+data.type+".mmn", File.READ) == OK:
|
if file.open("res://addons/material_maker/library/"+data.type+".mml", File.READ) == OK:
|
||||||
|
var model_data = parse_json(file.get_as_text())
|
||||||
|
print("loaded description "+data.type+".mml")
|
||||||
|
generator = create_gen(model_data)
|
||||||
|
file.close()
|
||||||
|
elif file.open("res://addons/material_maker/nodes/"+data.type+".mmn", File.READ) == OK:
|
||||||
|
generator = MMGenShader.new()
|
||||||
var model_data = parse_json(file.get_as_text())
|
var model_data = parse_json(file.get_as_text())
|
||||||
print("loaded description "+data.type+".mmn")
|
print("loaded description "+data.type+".mmn")
|
||||||
generator.set_model_data(model_data)
|
generator.set_model_data(model_data)
|
||||||
@ -36,6 +41,10 @@ func create_gen(data) -> MMGenBase:
|
|||||||
print("Cannot find description for "+data.type)
|
print("Cannot find description for "+data.type)
|
||||||
else:
|
else:
|
||||||
print(data)
|
print(data)
|
||||||
if generator != null and data.has("parameters"):
|
if generator != null:
|
||||||
|
if data.has("node_position"):
|
||||||
|
generator.position.x = data.node_position.x
|
||||||
|
generator.position.y = data.node_position.y
|
||||||
|
if data.has("parameters"):
|
||||||
generator.initialize(data)
|
generator.initialize(data)
|
||||||
return generator
|
return generator
|
||||||
|
@ -5,9 +5,11 @@ var editor_interface = null
|
|||||||
var node_factory = null
|
var node_factory = null
|
||||||
var renderer = null
|
var renderer = null
|
||||||
|
|
||||||
var save_path = null
|
var save_path = null setget set_save_path
|
||||||
var need_save = false
|
var need_save = false
|
||||||
|
|
||||||
|
var generator = null
|
||||||
|
|
||||||
signal save_path_changed
|
signal save_path_changed
|
||||||
signal graph_changed
|
signal graph_changed
|
||||||
|
|
||||||
@ -141,48 +143,28 @@ func create_nodes(data, position = null):
|
|||||||
connect_node(names[c.from], c.from_port, "Material" if c.to == "Material" else names[c.to], c.to_port)
|
connect_node(names[c.from], c.from_port, "Material" if c.to == "Material" else names[c.to], c.to_port)
|
||||||
return null
|
return null
|
||||||
|
|
||||||
func load_file():
|
func load_file(filename):
|
||||||
var dialog = FileDialog.new()
|
|
||||||
add_child(dialog)
|
|
||||||
dialog.rect_min_size = Vector2(500, 500)
|
|
||||||
dialog.access = FileDialog.ACCESS_FILESYSTEM
|
|
||||||
dialog.mode = FileDialog.MODE_OPEN_FILE
|
|
||||||
dialog.add_filter("*.ptex;Procedural textures file")
|
|
||||||
dialog.connect("file_selected", self, "do_load_file")
|
|
||||||
dialog.popup_centered()
|
|
||||||
|
|
||||||
func do_load_file(filename):
|
|
||||||
var file = File.new()
|
|
||||||
if file.open(filename, File.READ) != OK:
|
|
||||||
return
|
|
||||||
var data = parse_json(file.get_as_text())
|
|
||||||
file.close()
|
|
||||||
clear_material()
|
clear_material()
|
||||||
for n in data.nodes:
|
var loader = MMGenLoader.new()
|
||||||
create_nodes(n)
|
generator = loader.load_gen(filename)
|
||||||
for c in data.connections:
|
if generator != null:
|
||||||
connect_node(c.from, c.from_port, c.to, c.to_port)
|
add_child(generator)
|
||||||
|
for g in generator.get_children():
|
||||||
|
print(g.get_type())
|
||||||
|
var node = node_factory.create_node(g.get_type())
|
||||||
|
if node != null:
|
||||||
|
node.name = "node_"+g.name
|
||||||
|
add_node(node)
|
||||||
|
node.generator = g
|
||||||
|
node.offset = g.position
|
||||||
|
if generator.get("connections") != null:
|
||||||
|
for c in generator.connections:
|
||||||
|
.connect_node("node_"+c.from, c.from_port, "node_"+c.to, c.to_port)
|
||||||
set_save_path(filename)
|
set_save_path(filename)
|
||||||
set_need_save(false)
|
set_need_save(false)
|
||||||
center_view()
|
center_view()
|
||||||
|
|
||||||
func save_file():
|
func save_file(filename):
|
||||||
if save_path != null:
|
|
||||||
do_save_file(save_path)
|
|
||||||
else:
|
|
||||||
save_file_as()
|
|
||||||
|
|
||||||
func save_file_as():
|
|
||||||
var dialog = FileDialog.new()
|
|
||||||
add_child(dialog)
|
|
||||||
dialog.rect_min_size = Vector2(500, 500)
|
|
||||||
dialog.access = FileDialog.ACCESS_FILESYSTEM
|
|
||||||
dialog.mode = FileDialog.MODE_SAVE_FILE
|
|
||||||
dialog.add_filter("*.ptex;Procedural textures file")
|
|
||||||
dialog.connect("file_selected", self, "do_save_file")
|
|
||||||
dialog.popup_centered()
|
|
||||||
|
|
||||||
func do_save_file(filename):
|
|
||||||
var data = { nodes = [] }
|
var data = { nodes = [] }
|
||||||
for c in get_children():
|
for c in get_children():
|
||||||
if c is GraphNode:
|
if c is GraphNode:
|
||||||
@ -270,7 +252,7 @@ func center_view():
|
|||||||
|
|
||||||
func send_changed_signal():
|
func send_changed_signal():
|
||||||
set_need_save(true)
|
set_need_save(true)
|
||||||
$Timer.start()
|
#$Timer.start()
|
||||||
|
|
||||||
func do_send_changed_signal():
|
func do_send_changed_signal():
|
||||||
emit_signal("graph_changed")
|
emit_signal("graph_changed")
|
||||||
|
@ -1,54 +1,30 @@
|
|||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://addons/material_maker/graph_edit.gd" type="Script" id=1]
|
[ext_resource path="res://addons/material_maker/graph_edit.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://addons/material_maker/nodes/material/material.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://addons/material_maker/nodes/material.tscn" type="PackedScene" id=2]
|
||||||
|
|
||||||
[sub_resource type="Theme" id=1]
|
[sub_resource type="Theme" id=1]
|
||||||
|
|
||||||
|
[node name="GraphEdit" type="GraphEdit"]
|
||||||
[node name="GraphEdit" type="GraphEdit" index="0"]
|
|
||||||
|
|
||||||
self_modulate = Color( 1, 1, 1, 0 )
|
self_modulate = Color( 1, 1, 1, 0 )
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = true
|
|
||||||
focus_mode = 2
|
|
||||||
mouse_filter = 0
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 1
|
|
||||||
size_flags_vertical = 1
|
|
||||||
right_disconnects = true
|
right_disconnects = true
|
||||||
scroll_offset = Vector2( -458.75, -292.25 )
|
scroll_offset = Vector2( -325, -250 )
|
||||||
snap_distance = 20
|
|
||||||
use_snap = false
|
use_snap = false
|
||||||
zoom = 1.0
|
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
_sections_unfolded = [ "Material", "Mouse", "Visibility" ]
|
|
||||||
|
|
||||||
[node name="Material" parent="." index="0" instance=ExtResource( 2 )]
|
[node name="Material" parent="." instance=ExtResource( 2 )]
|
||||||
|
margin_left = 525.0
|
||||||
margin_left = 658.75
|
margin_top = 250.0
|
||||||
margin_top = 292.25
|
margin_right = 755.0
|
||||||
margin_right = 888.75
|
margin_bottom = 470.0
|
||||||
margin_bottom = 512.25
|
|
||||||
theme = SubResource( 1 )
|
theme = SubResource( 1 )
|
||||||
offset = Vector2( 200, 0 )
|
offset = Vector2( 200, 0 )
|
||||||
_sections_unfolded = [ "Anchor", "Margin", "Mouse", "Theme", "slot", "slot/0", "slot/1", "slot/2", "slot/3", "slot/4", "slot/5" ]
|
|
||||||
|
|
||||||
[node name="Timer" type="Timer" parent="." index="1"]
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
|
||||||
process_mode = 1
|
|
||||||
wait_time = 0.2
|
wait_time = 0.2
|
||||||
one_shot = true
|
one_shot = true
|
||||||
autostart = false
|
|
||||||
|
|
||||||
[connection signal="connection_request" from="." to="." method="connect_node"]
|
[connection signal="connection_request" from="." to="." method="connect_node"]
|
||||||
|
|
||||||
[connection signal="disconnection_request" from="." to="." method="disconnect_node"]
|
[connection signal="disconnection_request" from="." to="." method="disconnect_node"]
|
||||||
|
|
||||||
[connection signal="timeout" from="Timer" to="." method="do_send_changed_signal"]
|
[connection signal="timeout" from="Timer" to="." method="do_send_changed_signal"]
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ var recent_files_submenu = null
|
|||||||
var editor_interface = null
|
var editor_interface = null
|
||||||
var current_tab = null
|
var current_tab = null
|
||||||
|
|
||||||
|
onready var renderer = $Renderer
|
||||||
|
|
||||||
const MENU = [
|
const MENU = [
|
||||||
{ menu="File", command="new_material", description="New material" },
|
{ menu="File", command="new_material", description="New material" },
|
||||||
{ menu="File", command="load_material", shortcut="Control+O", description="Load material" },
|
{ menu="File", command="load_material", shortcut="Control+O", description="Load material" },
|
||||||
@ -140,7 +142,6 @@ func load_material():
|
|||||||
dialog.access = FileDialog.ACCESS_FILESYSTEM
|
dialog.access = FileDialog.ACCESS_FILESYSTEM
|
||||||
dialog.mode = FileDialog.MODE_OPEN_FILES
|
dialog.mode = FileDialog.MODE_OPEN_FILES
|
||||||
dialog.add_filter("*.ptex;Procedural textures file")
|
dialog.add_filter("*.ptex;Procedural textures file")
|
||||||
#dialog.connect("file_selected", self, "do_load_material")
|
|
||||||
dialog.connect("files_selected", self, "do_load_materials")
|
dialog.connect("files_selected", self, "do_load_materials")
|
||||||
dialog.popup_centered()
|
dialog.popup_centered()
|
||||||
|
|
||||||
@ -150,10 +151,8 @@ func do_load_materials(filenames):
|
|||||||
|
|
||||||
func do_load_material(filename):
|
func do_load_material(filename):
|
||||||
var graph_edit = $VBoxContainer/HBoxContainer/Projects.get_current_tab_control()
|
var graph_edit = $VBoxContainer/HBoxContainer/Projects.get_current_tab_control()
|
||||||
var node_count = 0
|
var node_count = 2 # So test below succeeds if graph_edit is null...
|
||||||
if graph_edit == null:
|
if graph_edit != null:
|
||||||
node_count = 123 # So test below succeeds...
|
|
||||||
else:
|
|
||||||
for c in graph_edit.get_children():
|
for c in graph_edit.get_children():
|
||||||
if c is GraphNode:
|
if c is GraphNode:
|
||||||
node_count += 1
|
node_count += 1
|
||||||
@ -161,18 +160,28 @@ func do_load_material(filename):
|
|||||||
break
|
break
|
||||||
if node_count > 1:
|
if node_count > 1:
|
||||||
graph_edit = new_pane()
|
graph_edit = new_pane()
|
||||||
graph_edit.do_load_file(filename)
|
graph_edit.load_file(filename)
|
||||||
add_recent(filename)
|
add_recent(filename)
|
||||||
|
|
||||||
func save_material():
|
func save_material():
|
||||||
var graph_edit = $VBoxContainer/HBoxContainer/Projects.get_current_tab_control()
|
var graph_edit = $VBoxContainer/HBoxContainer/Projects.get_current_tab_control()
|
||||||
if graph_edit != null:
|
if graph_edit != null:
|
||||||
graph_edit.save_file()
|
if graph_edit.save_path != null:
|
||||||
|
graph_edit.save_file(graph_edit.save_path)
|
||||||
|
else:
|
||||||
|
save_material_as()
|
||||||
|
|
||||||
func save_material_as():
|
func save_material_as():
|
||||||
var graph_edit = $VBoxContainer/HBoxContainer/Projects.get_current_tab_control()
|
var graph_edit = $VBoxContainer/HBoxContainer/Projects.get_current_tab_control()
|
||||||
if graph_edit != null:
|
if graph_edit != null:
|
||||||
graph_edit.save_file_as()
|
var dialog = FileDialog.new()
|
||||||
|
add_child(dialog)
|
||||||
|
dialog.rect_min_size = Vector2(500, 500)
|
||||||
|
dialog.access = FileDialog.ACCESS_FILESYSTEM
|
||||||
|
dialog.mode = FileDialog.MODE_SAVE_FILE
|
||||||
|
dialog.add_filter("*.ptex;Procedural textures file")
|
||||||
|
dialog.connect("file_selected", graph_edit, "save_file")
|
||||||
|
dialog.popup_centered()
|
||||||
|
|
||||||
func close_material():
|
func close_material():
|
||||||
$VBoxContainer/HBoxContainer/Projects.close_tab()
|
$VBoxContainer/HBoxContainer/Projects.close_tab()
|
||||||
@ -298,7 +307,17 @@ func update_preview_2d(node = null):
|
|||||||
node = n
|
node = n
|
||||||
break
|
break
|
||||||
if node != null:
|
if node != null:
|
||||||
graph_edit.renderer.setup_material(preview.get_2d_material(), node.get_textures(), node.generate_shader())
|
print(node.name)
|
||||||
|
var source = node.generator.get_shader(0)
|
||||||
|
if source != null:
|
||||||
|
var shader : String = renderer.generate_shader(source)
|
||||||
|
var status = renderer.render_shader(shader, {}, 1024)
|
||||||
|
while status is GDScriptFunctionState:
|
||||||
|
status = yield(status, "completed")
|
||||||
|
var image = renderer.get_texture().get_data()
|
||||||
|
var tex = ImageTexture.new()
|
||||||
|
tex.create_from_image(image)
|
||||||
|
preview.set_2d(tex)
|
||||||
|
|
||||||
func _on_Projects_tab_changed(tab):
|
func _on_Projects_tab_changed(tab):
|
||||||
var new_tab = $VBoxContainer/HBoxContainer/Projects.get_current_tab_control()
|
var new_tab = $VBoxContainer/HBoxContainer/Projects.get_current_tab_control()
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
[ext_resource path="res://addons/material_maker/library.gd" type="Script" id=2]
|
[ext_resource path="res://addons/material_maker/library.gd" type="Script" id=2]
|
||||||
[ext_resource path="res://addons/material_maker/preview.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://addons/material_maker/preview.tscn" type="PackedScene" id=3]
|
||||||
[ext_resource path="res://addons/material_maker/widgets/tabs.gd" type="Script" id=4]
|
[ext_resource path="res://addons/material_maker/widgets/tabs.gd" type="Script" id=4]
|
||||||
[ext_resource path="res://addons/material_maker/renderer.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://addons/material_maker/engine/renderer.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://addons/material_maker/node_factory.gd" type="Script" id=6]
|
[ext_resource path="res://addons/material_maker/node_factory.gd" type="Script" id=6]
|
||||||
|
|
||||||
[node name="MainWindow" type="Panel"]
|
[node name="MainWindow" type="Panel"]
|
||||||
@ -96,12 +96,6 @@ tab_align = 0
|
|||||||
tab_close_display_policy = 1
|
tab_close_display_policy = 1
|
||||||
|
|
||||||
[node name="Renderer" parent="." instance=ExtResource( 5 )]
|
[node name="Renderer" parent="." instance=ExtResource( 5 )]
|
||||||
handle_input_locally = false
|
|
||||||
msaa = 0
|
|
||||||
hdr = true
|
|
||||||
disable_3d = true
|
|
||||||
usage = 0
|
|
||||||
debug_path = "D:/Dev/mmdebug_"
|
|
||||||
|
|
||||||
[node name="NodeFactory" type="Node" parent="."]
|
[node name="NodeFactory" type="Node" parent="."]
|
||||||
script = ExtResource( 6 )
|
script = ExtResource( 6 )
|
||||||
|
1
addons/material_maker/new.ptex
Normal file
1
addons/material_maker/new.ptex
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"connections":[],"nodes":[{"name":"Material","node_position":{"x":307,"y":-53},"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"}]}
|
@ -12,7 +12,7 @@ func create_node(type):
|
|||||||
node = preload("res://addons/material_maker/nodes/node_generic.gd").new()
|
node = preload("res://addons/material_maker/nodes/node_generic.gd").new()
|
||||||
node.model = type
|
node.model = type
|
||||||
else:
|
else:
|
||||||
var node_type = load("res://addons/material_maker/nodes/"+type+"/"+type+".tscn")
|
var node_type = load("res://addons/material_maker/nodes/"+type+".tscn")
|
||||||
if node_type != null:
|
if node_type != null:
|
||||||
node = node_type.instance()
|
node = node_type.instance()
|
||||||
return node
|
return node
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://addons/material_maker/nodes/custom/custom.gd" type="Script" id=1]
|
[ext_resource path="res://addons/material_maker/nodes/custom.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://addons/material_maker/icons/edit.png" type="Texture" id=2]
|
[ext_resource path="res://addons/material_maker/icons/edit.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://addons/material_maker/icons/load.png" type="Texture" id=3]
|
[ext_resource path="res://addons/material_maker/icons/load.png" type="Texture" id=3]
|
||||||
[ext_resource path="res://addons/material_maker/icons/save.png" type="Texture" id=4]
|
[ext_resource path="res://addons/material_maker/icons/save.png" type="Texture" id=4]
|
134
addons/material_maker/nodes/generic.gd
Normal file
134
addons/material_maker/nodes/generic.gd
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
extends GraphNode
|
||||||
|
|
||||||
|
var generator = null setget set_generator
|
||||||
|
|
||||||
|
var uses_seed : bool = false
|
||||||
|
|
||||||
|
var parameters = {}
|
||||||
|
var model_data = {}
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
func set_generator(g):
|
||||||
|
generator = g
|
||||||
|
update_node(g.model_data)
|
||||||
|
|
||||||
|
func initialize_properties(p):
|
||||||
|
pass
|
||||||
|
|
||||||
|
func update_node(data):
|
||||||
|
print("node_generic.update_node")
|
||||||
|
if typeof(data) != TYPE_DICTIONARY:
|
||||||
|
return
|
||||||
|
if !data.has("name"):
|
||||||
|
return
|
||||||
|
# Clean node
|
||||||
|
parameters = {}
|
||||||
|
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
|
||||||
|
# Rebuild node
|
||||||
|
title = data.name
|
||||||
|
model_data = data
|
||||||
|
uses_seed = false
|
||||||
|
if model_data.has("instance") and model_data.instance.find("$(seed)"):
|
||||||
|
uses_seed = true
|
||||||
|
if model_data.has("parameters") and typeof(model_data.parameters) == TYPE_ARRAY:
|
||||||
|
var control_list = []
|
||||||
|
var sizer = null
|
||||||
|
for p in model_data.parameters:
|
||||||
|
if !p.has("name") or !p.has("type"):
|
||||||
|
continue
|
||||||
|
var control = null
|
||||||
|
if p.type == "float":
|
||||||
|
if p.has("widget") and p.widget == "spinbox":
|
||||||
|
control = SpinBox.new()
|
||||||
|
else:
|
||||||
|
control = HSlider.new()
|
||||||
|
control.min_value = p.min
|
||||||
|
control.max_value = p.max
|
||||||
|
control.step = 0 if !p.has("step") else p.step
|
||||||
|
if p.has("default"):
|
||||||
|
control.value = p.default
|
||||||
|
control.rect_min_size.x = 80
|
||||||
|
parameters[p.name] = 0.5*(p.min+p.max)
|
||||||
|
elif p.type == "size":
|
||||||
|
control = OptionButton.new()
|
||||||
|
for i in range(p.first, p.last+1):
|
||||||
|
var s = pow(2, i)
|
||||||
|
control.add_item("%dx%d" % [ s, s ])
|
||||||
|
control.selected = 0 if !p.has("default") else p.default-p.first
|
||||||
|
elif p.type == "enum":
|
||||||
|
control = OptionButton.new()
|
||||||
|
for i in range(p.values.size()):
|
||||||
|
var value = p.values[i]
|
||||||
|
control.add_item(value.name)
|
||||||
|
control.selected = 0 if !p.has("default") else p.default
|
||||||
|
elif p.type == "boolean":
|
||||||
|
control = CheckBox.new()
|
||||||
|
elif p.type == "color":
|
||||||
|
control = ColorPickerButton.new()
|
||||||
|
elif p.type == "gradient":
|
||||||
|
control = preload("res://addons/material_maker/widgets/gradient_editor.tscn").instance()
|
||||||
|
if control != null:
|
||||||
|
var label = p.name
|
||||||
|
control.name = label
|
||||||
|
control_list.append(control)
|
||||||
|
if p.has("label"):
|
||||||
|
label = p.label
|
||||||
|
if sizer == null or label != "nonewline":
|
||||||
|
sizer = HBoxContainer.new()
|
||||||
|
sizer.size_flags_horizontal = SIZE_EXPAND | SIZE_FILL
|
||||||
|
add_child(sizer)
|
||||||
|
if label != "" && label != "nonewline":
|
||||||
|
var label_widget = Label.new()
|
||||||
|
label_widget.text = label
|
||||||
|
label_widget.size_flags_horizontal = SIZE_EXPAND | SIZE_FILL
|
||||||
|
sizer.add_child(label_widget)
|
||||||
|
control.size_flags_horizontal = SIZE_EXPAND | SIZE_FILL
|
||||||
|
sizer.add_child(control)
|
||||||
|
initialize_properties(control_list)
|
||||||
|
else:
|
||||||
|
model_data.parameters = []
|
||||||
|
if model_data.has("inputs") and typeof(model_data.inputs) == TYPE_ARRAY:
|
||||||
|
for i in range(model_data.inputs.size()):
|
||||||
|
var input = model_data.inputs[i]
|
||||||
|
var enable_left = false
|
||||||
|
var color_left = Color(0.5, 0.5, 0.5)
|
||||||
|
if typeof(input) == TYPE_DICTIONARY:
|
||||||
|
if input.type == "rgb":
|
||||||
|
enable_left = true
|
||||||
|
color_left = Color(0.5, 0.5, 1.0)
|
||||||
|
elif input.type == "rgba":
|
||||||
|
enable_left = true
|
||||||
|
color_left = Color(0.0, 0.5, 0.0, 0.5)
|
||||||
|
else:
|
||||||
|
enable_left = true
|
||||||
|
set_slot(i, enable_left, 0, color_left, false, 0, Color())
|
||||||
|
else:
|
||||||
|
model_data.inputs = []
|
||||||
|
if model_data.has("outputs") and typeof(model_data.outputs) == TYPE_ARRAY:
|
||||||
|
for i in range(model_data.outputs.size()):
|
||||||
|
var output = model_data.outputs[i]
|
||||||
|
var enable_right = false
|
||||||
|
var color_right = Color(0.5, 0.5, 0.5)
|
||||||
|
if typeof(output) == TYPE_DICTIONARY:
|
||||||
|
if output.has("rgb"):
|
||||||
|
enable_right = true
|
||||||
|
color_right = Color(0.5, 0.5, 1.0)
|
||||||
|
elif output.has("rgba"):
|
||||||
|
enable_right = true
|
||||||
|
color_right = Color(0.0, 0.5, 0.0, 0.5)
|
||||||
|
elif output.has("f"):
|
||||||
|
enable_right = true
|
||||||
|
set_slot(i, is_slot_enabled_left(i), get_slot_type_left(i), get_slot_color_left(i), enable_right, 0, color_right)
|
||||||
|
else:
|
||||||
|
model_data.outputs = []
|
||||||
|
if custom_node_buttons != null:
|
||||||
|
move_child(custom_node_buttons, get_child_count()-1)
|
10
addons/material_maker/nodes/generic.tscn
Normal file
10
addons/material_maker/nodes/generic.tscn
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://addons/material_maker/nodes/generic.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Generic" type="GraphNode"]
|
||||||
|
margin_right = 82.0
|
||||||
|
margin_bottom = 29.0
|
||||||
|
title = "Generic"
|
||||||
|
show_close = true
|
||||||
|
script = ExtResource( 1 )
|
@ -1,6 +1,8 @@
|
|||||||
tool
|
tool
|
||||||
extends "res://addons/material_maker/node_base.gd"
|
extends "res://addons/material_maker/node_base.gd"
|
||||||
|
|
||||||
|
var generator = null
|
||||||
|
|
||||||
var texture_list
|
var texture_list
|
||||||
|
|
||||||
var current_material_list = []
|
var current_material_list = []
|
@ -1,12 +1,10 @@
|
|||||||
[gd_scene load_steps=3 format=2]
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://addons/material_maker/nodes/material/material.gd" type="Script" id=1]
|
[ext_resource path="res://addons/material_maker/nodes/material.gd" type="Script" id=1]
|
||||||
|
|
||||||
[sub_resource type="Theme" id=1]
|
[sub_resource type="Theme" id=1]
|
||||||
|
|
||||||
|
|
||||||
[node name="Material" type="GraphNode" index="0"]
|
[node name="Material" type="GraphNode" index="0"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -79,7 +77,6 @@ script = ExtResource( 1 )
|
|||||||
_sections_unfolded = [ "Theme", "slot", "slot/0", "slot/1", "slot/2", "slot/5", "slot/7" ]
|
_sections_unfolded = [ "Theme", "slot", "slot/0", "slot/1", "slot/2", "slot/5", "slot/7" ]
|
||||||
|
|
||||||
[node name="resolution" type="OptionButton" parent="." index="0"]
|
[node name="resolution" type="OptionButton" parent="." index="0"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -107,7 +104,6 @@ items = [ "256x256", null, false, 0, null, "512x512", null, false, 1, null, "102
|
|||||||
selected = 1
|
selected = 1
|
||||||
|
|
||||||
[node name="Albedo" type="HBoxContainer" parent="." index="1"]
|
[node name="Albedo" type="HBoxContainer" parent="." index="1"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -125,7 +121,6 @@ size_flags_vertical = 1
|
|||||||
alignment = 0
|
alignment = 0
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="Albedo" index="0"]
|
[node name="Label" type="Label" parent="Albedo" index="0"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -146,7 +141,6 @@ max_lines_visible = -1
|
|||||||
_sections_unfolded = [ "Size Flags" ]
|
_sections_unfolded = [ "Size Flags" ]
|
||||||
|
|
||||||
[node name="albedo_color" type="ColorPickerButton" parent="Albedo" index="1"]
|
[node name="albedo_color" type="ColorPickerButton" parent="Albedo" index="1"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -173,7 +167,6 @@ edit_alpha = false
|
|||||||
_sections_unfolded = [ "Rect", "Size Flags" ]
|
_sections_unfolded = [ "Rect", "Size Flags" ]
|
||||||
|
|
||||||
[node name="Metallic" type="HBoxContainer" parent="." index="2"]
|
[node name="Metallic" type="HBoxContainer" parent="." index="2"]
|
||||||
|
|
||||||
editor/display_folded = true
|
editor/display_folded = true
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
@ -192,7 +185,6 @@ size_flags_vertical = 1
|
|||||||
alignment = 0
|
alignment = 0
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="Metallic" index="0"]
|
[node name="Label" type="Label" parent="Metallic" index="0"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -213,7 +205,6 @@ max_lines_visible = -1
|
|||||||
_sections_unfolded = [ "Size Flags" ]
|
_sections_unfolded = [ "Size Flags" ]
|
||||||
|
|
||||||
[node name="metallic" type="SpinBox" parent="Metallic" index="1"]
|
[node name="metallic" type="SpinBox" parent="Metallic" index="1"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -240,7 +231,6 @@ suffix = ""
|
|||||||
_sections_unfolded = [ "Rect" ]
|
_sections_unfolded = [ "Rect" ]
|
||||||
|
|
||||||
[node name="Roughness" type="HBoxContainer" parent="." index="3"]
|
[node name="Roughness" type="HBoxContainer" parent="." index="3"]
|
||||||
|
|
||||||
editor/display_folded = true
|
editor/display_folded = true
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
@ -259,7 +249,6 @@ size_flags_vertical = 1
|
|||||||
alignment = 0
|
alignment = 0
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="Roughness" index="0"]
|
[node name="Label" type="Label" parent="Roughness" index="0"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -280,7 +269,6 @@ max_lines_visible = -1
|
|||||||
_sections_unfolded = [ "Size Flags" ]
|
_sections_unfolded = [ "Size Flags" ]
|
||||||
|
|
||||||
[node name="roughness" type="SpinBox" parent="Roughness" index="1"]
|
[node name="roughness" type="SpinBox" parent="Roughness" index="1"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -307,7 +295,6 @@ suffix = ""
|
|||||||
_sections_unfolded = [ "Rect" ]
|
_sections_unfolded = [ "Rect" ]
|
||||||
|
|
||||||
[node name="Emission" type="HBoxContainer" parent="." index="4"]
|
[node name="Emission" type="HBoxContainer" parent="." index="4"]
|
||||||
|
|
||||||
editor/display_folded = true
|
editor/display_folded = true
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
@ -326,7 +313,6 @@ size_flags_vertical = 1
|
|||||||
alignment = 0
|
alignment = 0
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="Emission" index="0"]
|
[node name="Label" type="Label" parent="Emission" index="0"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -347,7 +333,6 @@ max_lines_visible = -1
|
|||||||
_sections_unfolded = [ "Size Flags" ]
|
_sections_unfolded = [ "Size Flags" ]
|
||||||
|
|
||||||
[node name="emission_energy" type="SpinBox" parent="Emission" index="1"]
|
[node name="emission_energy" type="SpinBox" parent="Emission" index="1"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -374,7 +359,6 @@ suffix = ""
|
|||||||
_sections_unfolded = [ "Rect" ]
|
_sections_unfolded = [ "Rect" ]
|
||||||
|
|
||||||
[node name="NormalMap" type="HBoxContainer" parent="." index="5"]
|
[node name="NormalMap" type="HBoxContainer" parent="." index="5"]
|
||||||
|
|
||||||
editor/display_folded = true
|
editor/display_folded = true
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
@ -393,7 +377,6 @@ size_flags_vertical = 1
|
|||||||
alignment = 0
|
alignment = 0
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="NormalMap" index="0"]
|
[node name="Label" type="Label" parent="NormalMap" index="0"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -414,7 +397,6 @@ max_lines_visible = -1
|
|||||||
_sections_unfolded = [ "Size Flags" ]
|
_sections_unfolded = [ "Size Flags" ]
|
||||||
|
|
||||||
[node name="normal_scale" type="SpinBox" parent="NormalMap" index="1"]
|
[node name="normal_scale" type="SpinBox" parent="NormalMap" index="1"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -441,7 +423,6 @@ suffix = ""
|
|||||||
_sections_unfolded = [ "Rect" ]
|
_sections_unfolded = [ "Rect" ]
|
||||||
|
|
||||||
[node name="AmbientOcclusion" type="HBoxContainer" parent="." index="6"]
|
[node name="AmbientOcclusion" type="HBoxContainer" parent="." index="6"]
|
||||||
|
|
||||||
editor/display_folded = true
|
editor/display_folded = true
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
@ -460,7 +441,6 @@ size_flags_vertical = 1
|
|||||||
alignment = 0
|
alignment = 0
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="AmbientOcclusion" index="0"]
|
[node name="Label" type="Label" parent="AmbientOcclusion" index="0"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -481,7 +461,6 @@ max_lines_visible = -1
|
|||||||
_sections_unfolded = [ "Size Flags" ]
|
_sections_unfolded = [ "Size Flags" ]
|
||||||
|
|
||||||
[node name="ao_light_affect" type="SpinBox" parent="AmbientOcclusion" index="1"]
|
[node name="ao_light_affect" type="SpinBox" parent="AmbientOcclusion" index="1"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -508,7 +487,6 @@ suffix = ""
|
|||||||
_sections_unfolded = [ "Rect" ]
|
_sections_unfolded = [ "Rect" ]
|
||||||
|
|
||||||
[node name="DepthMap" type="HBoxContainer" parent="." index="7"]
|
[node name="DepthMap" type="HBoxContainer" parent="." index="7"]
|
||||||
|
|
||||||
editor/display_folded = true
|
editor/display_folded = true
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
@ -527,7 +505,6 @@ size_flags_vertical = 1
|
|||||||
alignment = 0
|
alignment = 0
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="DepthMap" index="0"]
|
[node name="Label" type="Label" parent="DepthMap" index="0"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -548,7 +525,6 @@ max_lines_visible = -1
|
|||||||
_sections_unfolded = [ "Size Flags" ]
|
_sections_unfolded = [ "Size Flags" ]
|
||||||
|
|
||||||
[node name="depth_scale" type="SpinBox" parent="DepthMap" index="1"]
|
[node name="depth_scale" type="SpinBox" parent="DepthMap" index="1"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -573,5 +549,3 @@ editable = true
|
|||||||
prefix = ""
|
prefix = ""
|
||||||
suffix = ""
|
suffix = ""
|
||||||
_sections_unfolded = [ "Rect" ]
|
_sections_unfolded = [ "Rect" ]
|
||||||
|
|
||||||
|
|
@ -30,8 +30,8 @@ func _on_Model_item_selected(id):
|
|||||||
func get_materials():
|
func get_materials():
|
||||||
return [ $MaterialPreview/Objects/Cube.get_surface_material(0), $MaterialPreview/Objects/Sphere.get_surface_material(0) ]
|
return [ $MaterialPreview/Objects/Cube.get_surface_material(0), $MaterialPreview/Objects/Sphere.get_surface_material(0) ]
|
||||||
|
|
||||||
func get_2d_material():
|
func set_2d(tex: Texture):
|
||||||
return $Preview2D.material
|
$Preview2D.material.set_shader_param("tex", tex)
|
||||||
|
|
||||||
func _on_Preview_resized():
|
func _on_Preview_resized():
|
||||||
if preview_maximized:
|
if preview_maximized:
|
||||||
|
File diff suppressed because one or more lines are too long
@ -3,24 +3,10 @@
|
|||||||
[ext_resource path="res://addons/material_maker/main_window.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://addons/material_maker/main_window.tscn" type="PackedScene" id=1]
|
||||||
|
|
||||||
[node name="WindowDialog" type="WindowDialog"]
|
[node name="WindowDialog" type="WindowDialog"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_right = 1124.0
|
margin_right = 1124.0
|
||||||
margin_bottom = 619.0
|
margin_bottom = 619.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
mouse_filter = 0
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 1
|
|
||||||
size_flags_vertical = 1
|
|
||||||
popup_exclusive = true
|
popup_exclusive = true
|
||||||
window_title = "Material Maker"
|
window_title = "Material Maker"
|
||||||
resizable = true
|
resizable = true
|
||||||
_sections_unfolded = [ "Popup" ]
|
|
||||||
|
|
||||||
[node name="MainWindow" parent="." index="1" instance=ExtResource( 1 )]
|
|
||||||
|
|
||||||
|
|
||||||
|
[node name="MainWindow" parent="." instance=ExtResource( 1 )]
|
||||||
|
File diff suppressed because one or more lines are too long
@ -19,6 +19,11 @@ _global_script_classes=[ {
|
|||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/material_maker/engine/gen_buffer.gd"
|
"path": "res://addons/material_maker/engine/gen_buffer.gd"
|
||||||
}, {
|
}, {
|
||||||
|
"base": "Object",
|
||||||
|
"class": "MMGenContext",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://addons/material_maker/engine/gen_context.gd"
|
||||||
|
}, {
|
||||||
"base": "MMGenBase",
|
"base": "MMGenBase",
|
||||||
"class": "MMGenConvolution",
|
"class": "MMGenConvolution",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
@ -57,6 +62,7 @@ _global_script_classes=[ {
|
|||||||
_global_script_class_icons={
|
_global_script_class_icons={
|
||||||
"MMGenBase": "",
|
"MMGenBase": "",
|
||||||
"MMGenBuffer": "",
|
"MMGenBuffer": "",
|
||||||
|
"MMGenContext": "",
|
||||||
"MMGenConvolution": "",
|
"MMGenConvolution": "",
|
||||||
"MMGenGraph": "",
|
"MMGenGraph": "",
|
||||||
"MMGenLoader": "",
|
"MMGenLoader": "",
|
||||||
|
Loading…
Reference in New Issue
Block a user