Fixed generation of transparent images. Now in tools menu instead of a button in the toolbar.

This commit is contained in:
RodZill4 2019-04-13 19:44:37 +02:00
parent 0b7a36282e
commit 6984088b78
9 changed files with 86 additions and 403 deletions

View File

@ -277,7 +277,7 @@ func _on_PopupMenu_id_pressed(id):
var command = MENU[id].command var command = MENU[id].command
if has_method(command): if has_method(command):
call(command) call(command)
func _on_LoadRecent_id_pressed(id): func _on_LoadRecent_id_pressed(id):
do_load_material(recent_files[id]) do_load_material(recent_files[id])

View File

@ -7,276 +7,110 @@
[ext_resource path="res://addons/material_maker/renderer.tscn" type="PackedScene" id=5] [ext_resource path="res://addons/material_maker/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" index="0"] [node name="MainWindow" type="Panel"]
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 = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="VBoxContainer" type="VBoxContainer" parent="." index="0"] [node name="VBoxContainer" type="VBoxContainer" parent="."]
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 = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
alignment = 0
[node name="Menu" type="HBoxContainer" parent="VBoxContainer" index="0"] [node name="Menu" type="HBoxContainer" parent="VBoxContainer"]
margin_right = 1024.0
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 1280.0
margin_bottom = 20.0 margin_bottom = 20.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
[node name="File" type="MenuButton" parent="VBoxContainer/Menu" index="0"] [node name="File" type="MenuButton" parent="VBoxContainer/Menu"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 35.0 margin_right = 35.0
margin_bottom = 20.0 margin_bottom = 20.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
toggle_mode = false
action_mode = 0
enabled_focus_mode = 0
shortcut = null
group = null
text = "File" text = "File"
flat = true items = [ "New material", null, 0, false, false, 0, 0, null, "", false, "Load material", null, 0, false, false, 1, 268435535, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Save material", null, 0, false, false, 4, 268435539, null, "", false, "Save material as...", null, 0, false, false, 5, 301989971, null, "", false, "Save all materials...", null, 0, false, false, 6, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Export material", null, 0, false, false, 8, 268435525, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Close material", null, 0, false, false, 10, 0, null, "", false, "Quit", null, 0, false, false, 11, 268435537, null, "", false ]
align = 1
items = [ "New material", null, 0, false, false, 0, 0, null, "", false, "Load material", null, 0, false, false, 1, 268435535, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Save material", null, 0, false, false, 3, 268435539, null, "", false, "Save material as...", null, 0, false, false, 4, 301989971, null, "", false, "Save all materials...", null, 0, false, false, 5, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Export material", null, 0, false, false, 7, 268435525, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Close material", null, 0, false, false, 9, 0, null, "", false, "Quit", null, 0, false, false, 10, 268435537, null, "", false ]
[node name="Edit" type="MenuButton" parent="VBoxContainer/Menu" index="1"] [node name="Edit" type="MenuButton" parent="VBoxContainer/Menu"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 39.0 margin_left = 39.0
margin_right = 75.0 margin_right = 75.0
margin_bottom = 20.0 margin_bottom = 20.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
toggle_mode = false
action_mode = 0
enabled_focus_mode = 0
shortcut = null
group = null
text = "Edit" text = "Edit"
flat = true items = [ "Cut", null, 0, false, false, 12, 268435544, null, "", false, "Copy", null, 0, false, false, 13, 268435523, null, "", false, "Paste", null, 0, false, false, 14, 268435542, null, "", false ]
align = 1
items = [ "Cut", null, 0, false, false, 11, 268435544, null, "", false, "Copy", null, 0, false, false, 12, 268435523, null, "", false, "Paste", null, 0, false, false, 13, 268435542, null, "", false ]
[node name="Tools" type="MenuButton" parent="VBoxContainer/Menu" index="2"] [node name="Tools" type="MenuButton" parent="VBoxContainer/Menu"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 79.0 margin_left = 79.0
margin_right = 125.0 margin_right = 125.0
margin_bottom = 20.0 margin_bottom = 20.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
toggle_mode = false
action_mode = 0
enabled_focus_mode = 0
shortcut = null
group = null
text = "Tools" text = "Tools"
flat = true items = [ "Add selected node to user library", null, 0, false, false, 15, 0, null, "", false, "Save user library", null, 0, false, false, 16, 0, null, "", false ]
align = 1
items = [ "Add selected node to user library", null, 0, false, false, 14, 0, null, "", false, "Save user library", null, 0, false, false, 15, 0, null, "", false ]
[node name="Help" type="MenuButton" parent="VBoxContainer/Menu" index="3"] [node name="Help" type="MenuButton" parent="VBoxContainer/Menu"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 129.0 margin_left = 129.0
margin_right = 171.0 margin_right = 171.0
margin_bottom = 20.0 margin_bottom = 20.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
toggle_mode = false
action_mode = 0
enabled_focus_mode = 0
shortcut = null
group = null
text = "Help" text = "Help"
flat = true items = [ "User manual", null, 0, false, false, 17, 0, null, "", false, "Report a bug", null, 0, false, false, 18, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "About", null, 0, false, false, 20, 0, null, "", false ]
align = 1
items = [ "User manual", null, 0, false, false, 16, 0, null, "", false, "Report a bug", null, 0, false, false, 17, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "About", null, 0, false, false, 19, 0, null, "", false ]
[node name="HBoxContainer" type="HSplitContainer" parent="VBoxContainer" index="1"] [node name="HBoxContainer" type="HSplitContainer" parent="VBoxContainer"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 24.0 margin_top = 24.0
margin_right = 1280.0 margin_right = 1024.0
margin_bottom = 720.0 margin_bottom = 600.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 = 3 size_flags_vertical = 3
split_offset = 0
collapsed = false
dragger_visibility = 0
[node name="VBoxContainer" type="VSplitContainer" parent="VBoxContainer/HBoxContainer" index="0"] [node name="VBoxContainer" type="VSplitContainer" parent="VBoxContainer/HBoxContainer"]
margin_right = 250.0
anchor_left = 0.0 margin_bottom = 576.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 314.0
margin_bottom = 696.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
split_offset = 0
collapsed = false
dragger_visibility = 0
[node name="Library" type="Tree" parent="VBoxContainer/HBoxContainer/VBoxContainer" index="0"] [node name="Library" type="Tree" parent="VBoxContainer/HBoxContainer/VBoxContainer"]
margin_right = 250.0
anchor_left = 0.0 margin_bottom = 282.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 314.0
margin_bottom = 342.0
rect_min_size = Vector2( 100, 100 ) rect_min_size = Vector2( 100, 100 )
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = true
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
columns = 1
allow_reselect = false
allow_rmb_select = false
hide_folding = false
hide_root = true hide_root = true
drop_mode_flags = 0
select_mode = 0
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="Preview" parent="VBoxContainer/HBoxContainer/VBoxContainer" index="1" instance=ExtResource( 3 )] [node name="Preview" parent="VBoxContainer/HBoxContainer/VBoxContainer" instance=ExtResource( 3 )]
anchor_left = 0.0 anchor_left = 0.0
anchor_right = 0.0 anchor_right = 0.0
margin_left = 0.0 margin_left = 0.0
margin_top = 354.0 margin_top = 294.0
margin_right = 314.0 margin_right = 250.0
margin_bottom = 696.0 margin_bottom = 576.0
[node name="Projects" type="Panel" parent="VBoxContainer/HBoxContainer" index="1"] [node name="Projects" type="Panel" parent="VBoxContainer/HBoxContainer"]
margin_left = 262.0
anchor_left = 0.0 margin_right = 1024.0
anchor_top = 0.0 margin_bottom = 576.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 326.0
margin_right = 1280.0
margin_bottom = 696.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
size_flags_stretch_ratio = 3.0 size_flags_stretch_ratio = 3.0
script = ExtResource( 4 ) script = ExtResource( 4 )
[node name="Tabs" type="Tabs" parent="VBoxContainer/HBoxContainer/Projects" index="1"] [node name="Tabs" type="Tabs" parent="VBoxContainer/HBoxContainer/Projects"]
margin_right = 762.0
anchor_left = 0.0 margin_bottom = 24.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 954.0
margin_bottom = 21.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
tab_align = 0 tab_align = 0
tab_close_display_policy = 1 tab_close_display_policy = 1
scrolling_enabled = true
[node name="Renderer" parent="." index="1" instance=ExtResource( 5 )] [node name="Renderer" parent="." instance=ExtResource( 5 )]
handle_input_locally = false
[node name="NodeFactory" type="Node" parent="." index="2"] msaa = 0
hdr = true
disable_3d = true
usage = 0
debug_path = "D:/Dev/mmdebug_"
[node name="NodeFactory" type="Node" parent="."]
script = ExtResource( 6 ) script = ExtResource( 6 )
[connection signal="no_more_tabs" from="VBoxContainer/HBoxContainer/Projects" to="." method="new_material"] [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="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"] [connection signal="tab_changed" from="VBoxContainer/HBoxContainer/Projects" to="." method="_on_Projects_tab_changed"]
[connection signal="connection_request" from="VBoxContainer/HBoxContainer/Projects/GraphEdit" to="VBoxContainer/HBoxContainer/Projects/GraphEdit" method="connect_node"] [connection signal="connection_request" from="VBoxContainer/HBoxContainer/Projects/GraphEdit" to="VBoxContainer/HBoxContainer/Projects/GraphEdit" method="connect_node"]
[connection signal="disconnection_request" from="VBoxContainer/HBoxContainer/Projects/GraphEdit" to="VBoxContainer/HBoxContainer/Projects/GraphEdit" method="disconnect_node"] [connection signal="disconnection_request" from="VBoxContainer/HBoxContainer/Projects/GraphEdit" to="VBoxContainer/HBoxContainer/Projects/GraphEdit" method="disconnect_node"]
[connection signal="reposition_active_tab_request" from="VBoxContainer/HBoxContainer/Projects/Tabs" to="VBoxContainer/HBoxContainer/Projects" method="move_active_tab_to"] [connection signal="reposition_active_tab_request" from="VBoxContainer/HBoxContainer/Projects/Tabs" to="VBoxContainer/HBoxContainer/Projects" method="move_active_tab_to"]
[connection signal="tab_changed" from="VBoxContainer/HBoxContainer/Projects/Tabs" to="VBoxContainer/HBoxContainer/Projects" method="set_current_tab"] [connection signal="tab_changed" from="VBoxContainer/HBoxContainer/Projects/Tabs" to="VBoxContainer/HBoxContainer/Projects" method="set_current_tab"]
[connection signal="tab_close" from="VBoxContainer/HBoxContainer/Projects/Tabs" to="VBoxContainer/HBoxContainer/Projects" method="close_tab"] [connection signal="tab_close" from="VBoxContainer/HBoxContainer/Projects/Tabs" to="VBoxContainer/HBoxContainer/Projects" method="close_tab"]

View File

@ -2,32 +2,15 @@
[ext_resource path="res://addons/material_maker/nodes/export/export.gd" type="Script" id=1] [ext_resource path="res://addons/material_maker/nodes/export/export.gd" type="Script" id=1]
[sub_resource type="Theme" id=1] [sub_resource type="Theme" id=1]
[node name="Export" type="GraphNode"] [node name="Export" type="GraphNode"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 90.0 margin_right = 90.0
margin_bottom = 53.0 margin_bottom = 53.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1 mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
theme = SubResource( 1 ) theme = SubResource( 1 )
title = "Export" title = "Export"
offset = Vector2( 0, 0 )
show_close = true show_close = true
resizable = false
selected = false
comment = false
overlay = 0
slot/0/left_enabled = true slot/0/left_enabled = true
slot/0/left_type = 0 slot/0/left_type = 0
slot/0/left_color = Color( 0.5, 0.5, 1, 1 ) slot/0/left_color = Color( 0.5, 0.5, 1, 1 )
@ -41,61 +24,21 @@ slot/1/right_enabled = false
slot/1/right_type = 0 slot/1/right_type = 0
slot/1/right_color = Color( 1, 1, 1, 1 ) slot/1/right_color = Color( 1, 1, 1, 1 )
script = ExtResource( 1 ) script = ExtResource( 1 )
_sections_unfolded = [ "Theme", "slot", "slot/0" ]
[node name="resolution" type="OptionButton" parent="." index="0"] [node name="resolution" type="OptionButton" parent="."]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 16.0 margin_left = 16.0
margin_top = 24.0 margin_top = 24.0
margin_right = 126.0 margin_right = 126.0
margin_bottom = 44.0 margin_bottom = 44.0
rect_min_size = Vector2( 110, 0 ) rect_min_size = Vector2( 110, 0 )
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
action_mode = 0
enabled_focus_mode = 2
shortcut = null
group = null
text = "512x512" text = "512x512"
flat = false
align = 0
items = [ "256x256", null, false, 0, null, "512x512", null, false, 1, null, "1024x1024", null, false, 2, null, "2048x2048", null, false, -1, null ] items = [ "256x256", null, false, 0, null, "512x512", null, false, 1, null, "1024x1024", null, false, 2, null, "2048x2048", null, false, -1, null ]
selected = 1 selected = 1
_sections_unfolded = [ "Rect", "custom_constants" ]
[node name="Suffix" type="LineEdit" parent="." index="1"] [node name="Suffix" type="LineEdit" parent="."]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 16.0 margin_left = 16.0
margin_top = 44.0 margin_top = 44.0
margin_right = 126.0 margin_right = 126.0
margin_bottom = 68.0 margin_bottom = 68.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 1
size_flags_horizontal = 1
size_flags_vertical = 1
text = "suffix" text = "suffix"
focus_mode = 2
context_menu_enabled = true
placeholder_alpha = 0.6
caret_blink = false
caret_blink_speed = 0.65
caret_position = 0

View File

@ -27,8 +27,8 @@ func _get_shader_code(uv, slot = 0):
if variant_index == -1: if variant_index == -1:
variant_index = generated_variants.size() variant_index = generated_variants.size()
generated_variants.append(uv) generated_variants.append(uv)
rv.code = "vec3 %s_%d_rgb = texture(%s_tex, %s).rgb;\n" % [ name, variant_index, name, uv ] rv.code = "vec4 %s_%d_rgba = texture(%s_tex, %s);\n" % [ name, variant_index, name, uv ]
rv.rgb = "%s_%d_rgb" % [ name, variant_index ] rv.rgba = "%s_%d_rgba" % [ name, variant_index ]
return rv return rv
func _on_TextureButton_pressed(): func _on_TextureButton_pressed():

View File

@ -3,35 +3,18 @@
[ext_resource path="res://addons/material_maker/nodes/image/image.gd" type="Script" id=1] [ext_resource path="res://addons/material_maker/nodes/image/image.gd" type="Script" id=1]
[ext_resource path="res://addons/material_maker/nodes/image/godot_logo.png" type="Texture" id=2] [ext_resource path="res://addons/material_maker/nodes/image/godot_logo.png" type="Texture" id=2]
[sub_resource type="Theme" id=1] [sub_resource type="Theme" id=1]
[node name="Image" type="GraphNode"]
[node name="Image" type="GraphNode" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = -1.0 margin_left = -1.0
margin_top = -1.0 margin_top = -1.0
margin_right = 95.0 margin_right = 95.0
margin_bottom = 92.0 margin_bottom = 92.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1 mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
size_flags_stretch_ratio = 0.13 size_flags_stretch_ratio = 0.13
theme = SubResource( 1 ) theme = SubResource( 1 )
title = "Image" title = "Image"
offset = Vector2( 0, 0 )
show_close = true show_close = true
resizable = false
selected = false
comment = false
overlay = 0
slot/0/left_enabled = false slot/0/left_enabled = false
slot/0/left_type = 0 slot/0/left_type = 0
slot/0/left_color = Color( 0.5, 0.5, 1, 1 ) slot/0/left_color = Color( 0.5, 0.5, 1, 1 )
@ -39,35 +22,16 @@ slot/0/right_enabled = true
slot/0/right_type = 0 slot/0/right_type = 0
slot/0/right_color = Color( 0.5, 0.5, 1, 1 ) slot/0/right_color = Color( 0.5, 0.5, 1, 1 )
script = ExtResource( 1 ) script = ExtResource( 1 )
_sections_unfolded = [ "Mouse", "Size Flags", "Theme" ]
[node name="TextureButton" type="TextureButton" parent="." index="0"] [node name="TextureButton" type="TextureButton" parent="."]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 16.0 margin_left = 16.0
margin_top = 24.0 margin_top = 24.0
margin_right = 80.0 margin_right = 80.0
margin_bottom = 88.0 margin_bottom = 88.0
rect_min_size = Vector2( 64, 64 ) rect_min_size = Vector2( 64, 64 )
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = true rect_clip_content = true
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
texture_normal = ExtResource( 2 ) texture_normal = ExtResource( 2 )
expand = true expand = true
stretch_mode = 5 stretch_mode = 5
_sections_unfolded = [ "Rect", "Textures" ]
[connection signal="pressed" from="TextureButton" to="." method="_on_TextureButton_pressed"] [connection signal="pressed" from="TextureButton" to="." method="_on_TextureButton_pressed"]

View File

@ -5,15 +5,10 @@ var mm_button = null
var material_maker = null var material_maker = null
func _enter_tree(): func _enter_tree():
mm_button = Button.new() add_tool_menu_item("Material Maker", self, "open_material_maker")
mm_button.connect("pressed", self, "open_material_maker")
mm_button.text = "Material Maker"
add_control_to_container(CONTAINER_TOOLBAR, mm_button)
func _exit_tree(): func _exit_tree():
if mm_button != null: remove_tool_menu_item("Material Maker")
remove_control_from_container(CONTAINER_TOOLBAR, mm_button)
mm_button.queue_free()
if material_maker != null: if material_maker != null:
material_maker.hide() material_maker.hide()
material_maker.queue_free() material_maker.queue_free()
@ -27,7 +22,7 @@ func _set_state(s):
mm_button = s.mm_button mm_button = s.mm_button
material_maker = s.material_maker material_maker = s.material_maker
func open_material_maker(): func open_material_maker(foo = null):
if material_maker == null: if material_maker == null:
material_maker = preload("res://addons/material_maker/window_dialog.tscn").instance() material_maker = preload("res://addons/material_maker/window_dialog.tscn").instance()
var panel = material_maker.get_node("MainWindow") var panel = material_maker.get_node("MainWindow")

View File

@ -1,8 +1,12 @@
tool tool
extends Viewport extends Viewport
export(String) var debug_path = null
var debug_file_index = 0
var render_queue = [] var render_queue = []
func _ready(): func _ready():
$ColorRect.material = $ColorRect.material.duplicate(true) $ColorRect.material = $ColorRect.material.duplicate(true)
@ -11,6 +15,7 @@ func _ready():
static func generate_shader(src_code): static func generate_shader(src_code):
var code var code
code = "shader_type canvas_item;\n" code = "shader_type canvas_item;\n"
code += "render_mode blend_disabled;\n"
var file = File.new() var file = File.new()
file.open("res://addons/material_maker/common.shader", File.READ) file.open("res://addons/material_maker/common.shader", File.READ)
code += file.get_as_text() code += file.get_as_text()
@ -30,6 +35,7 @@ static func generate_shader(src_code):
static func generate_combined_shader(red_code, green_code, blue_code): static func generate_combined_shader(red_code, green_code, blue_code):
var code var code
code = "shader_type canvas_item;\n" code = "shader_type canvas_item;\n"
code += "render_mode blend_disabled;\n"
var file = File.new() var file = File.new()
file.open("res://addons/material_maker/common.shader", File.READ) file.open("res://addons/material_maker/common.shader", File.READ)
code += file.get_as_text() code += file.get_as_text()
@ -63,6 +69,12 @@ func setup_material(shader_material, textures, shader_code):
shader_material.shader.code = shader_code shader_material.shader.code = shader_code
func render_shader_to_viewport(shader, textures, render_size, method, args): func render_shader_to_viewport(shader, textures, render_size, method, args):
if debug_path != null and debug_path != "":
var f = File.new()
f.open(debug_path+str(debug_file_index)+".shader", File.WRITE)
f.store_string(shader)
f.close()
debug_file_index += 1
render_queue.append( { shader=shader, textures=textures, size=render_size, method=method, args=args } ) render_queue.append( { shader=shader, textures=textures, size=render_size, method=method, args=args } )
if render_queue.size() == 1: if render_queue.size() == 1:
while !render_queue.empty(): while !render_queue.empty():
@ -93,7 +105,13 @@ func export_texture(node, filename, render_size = 256):
func do_export_texture(filename): func do_export_texture(filename):
var viewport_texture = get_texture() var viewport_texture = get_texture()
var viewport_image = viewport_texture.get_data() var x = ImageTexture.new()
x.create_from_image(viewport_texture.get_data())
var viewport_image = x.get_data()
var f = File.new()
f.open(filename+".raw", File.WRITE)
f.store_buffer(viewport_image.get_data())
f.close()
viewport_image.save_png(filename) viewport_image.save_png(filename)
func precalculate_node(node, render_size, target_texture, object, method, args): func precalculate_node(node, render_size, target_texture, object, method, args):

View File

@ -1,101 +1,14 @@
[gd_resource type="Environment" load_steps=2 format=2] [gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1] [sub_resource type="ProceduralSky" id=1]
radiance_size = 4
sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 ) sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 )
sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 ) sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 )
sky_curve = 0.25 sky_curve = 0.25
sky_energy = 1.0
ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 ) ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 )
ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 ) ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 )
ground_curve = 0.01 ground_curve = 0.01
ground_energy = 1.0
sun_color = Color( 1, 1, 1, 1 )
sun_latitude = 35.0
sun_longitude = 0.0
sun_angle_min = 1.0
sun_angle_max = 100.0
sun_curve = 0.05
sun_energy = 16.0
texture_size = 2
[resource] [resource]
background_mode = 2 background_mode = 2
background_sky = SubResource( 1 ) background_sky = SubResource( 1 )
background_sky_custom_fov = 0.0
background_color = Color( 0, 0, 0, 1 )
background_energy = 1.0
background_canvas_max_layer = 0
ambient_light_color = Color( 0, 0, 0, 1 )
ambient_light_energy = 1.0
ambient_light_sky_contribution = 1.0
fog_enabled = false
fog_color = Color( 0.5, 0.6, 0.7, 1 )
fog_sun_color = Color( 1, 0.9, 0.7, 1 )
fog_sun_amount = 0.0
fog_depth_enabled = true
fog_depth_begin = 10.0
fog_depth_curve = 1.0
fog_transmit_enabled = false
fog_transmit_curve = 1.0
fog_height_enabled = false
fog_height_min = 0.0
fog_height_max = 100.0
fog_height_curve = 1.0
tonemap_mode = 0
tonemap_exposure = 1.0
tonemap_white = 1.0
auto_exposure_enabled = false
auto_exposure_scale = 0.4
auto_exposure_min_luma = 0.05
auto_exposure_max_luma = 8.0
auto_exposure_speed = 0.5
ss_reflections_enabled = false
ss_reflections_max_steps = 64
ss_reflections_fade_in = 0.15
ss_reflections_fade_out = 2.0
ss_reflections_depth_tolerance = 0.2
ss_reflections_roughness = true
ssao_enabled = false
ssao_radius = 1.0
ssao_intensity = 1.0
ssao_radius2 = 0.0
ssao_intensity2 = 1.0
ssao_bias = 0.01
ssao_light_affect = 0.0
ssao_color = Color( 0, 0, 0, 1 )
ssao_quality = 0
ssao_blur = 3
ssao_edge_sharpness = 4.0
dof_blur_far_enabled = false
dof_blur_far_distance = 10.0
dof_blur_far_transition = 5.0
dof_blur_far_amount = 0.1
dof_blur_far_quality = 1
dof_blur_near_enabled = false
dof_blur_near_distance = 2.0
dof_blur_near_transition = 1.0
dof_blur_near_amount = 0.1
dof_blur_near_quality = 1
glow_enabled = false
glow_levels/1 = false
glow_levels/2 = false
glow_levels/3 = true
glow_levels/4 = false
glow_levels/5 = true
glow_levels/6 = false
glow_levels/7 = false
glow_intensity = 0.8
glow_strength = 1.0
glow_bloom = 0.0
glow_blend_mode = 2
glow_hdr_threshold = 1.0
glow_hdr_scale = 2.0
glow_bicubic_upscale = false
adjustment_enabled = false
adjustment_brightness = 1.0
adjustment_contrast = 1.0
adjustment_saturation = 1.0

View File

@ -6,7 +6,12 @@
; [section] ; section goes between [] ; [section] ; section goes between []
; param=value ; assign values to parameters ; param=value ; assign values to parameters
config_version=3 config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application] [application]
@ -17,6 +22,13 @@ config/custom_user_dir_name="material_maker"
config/icon="res://icon.png" config/icon="res://icon.png"
config/release="0.6" config/release="0.6"
[debug]
gdscript/warnings/unsafe_property_access=true
gdscript/warnings/unsafe_method_access=true
gdscript/warnings/unsafe_cast=true
gdscript/warnings/unsafe_call_argument=true
[display] [display]
window/size/width=1280 window/size/width=1280
@ -26,6 +38,10 @@ window/size/height=720
enabled=PoolStringArray( "material_maker" ) enabled=PoolStringArray( "material_maker" )
[logging]
file_logging/enable_file_logging=true
[rendering] [rendering]
environment/default_environment="res://default_env.tres" environment/default_environment="res://default_env.tres"