Added export size selection in Material and Export nodes

This commit is contained in:
Rodolphe Suescun 2018-08-26 16:22:42 +02:00
parent 76f588a00e
commit 5669117b44
7 changed files with 118 additions and 40 deletions

View File

@ -191,7 +191,7 @@ func do_save_file(filename):
set_save_path(filename)
set_need_save(false)
func export_textures(size = 512):
func export_textures(size = null):
if save_path != null:
var prefix = save_path.left(save_path.rfind("."))
for c in get_children():

View File

@ -113,7 +113,7 @@ func close_material():
func export_material():
var graph_edit = $VBoxContainer/HBoxContainer/Projects.get_current_tab_control()
if graph_edit != null:
graph_edit.export_textures(256)
graph_edit.export_textures()
func quit():
if Engine.editor_hint:

View File

@ -147,7 +147,7 @@ group = null
text = "Help"
flat = true
align = 1
items = [ "Report a bug", null, 0, false, false, 16, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "About", null, 0, false, false, 18, 0, null, "", false ]
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"]

View File

@ -1,8 +1,11 @@
tool
extends "res://addons/procedural_material/node_base.gd"
var resolution = 1
var suffix = "suffix"
func _ready():
pass
initialize_properties([ $resolution ])
func _get_shader_code(uv):
var rv = { defs="", code="", f="0.0" }
@ -11,10 +14,12 @@ func _get_shader_code(uv):
rv = src.get_shader_code(uv)
return rv
func export_textures(prefix):
func export_textures(prefix, size = null):
var suffix = $Suffix.text
if suffix != "":
get_parent().export_texture(get_source(), "%s_%s.png" % [ prefix, suffix ], 1024)
if size == null:
size = int(pow(2, 8+resolution))
get_parent().export_texture(get_source(), "%s_%s.png" % [ prefix, suffix ], size)
func serialize():
var data = .serialize()

View File

@ -5,7 +5,7 @@
[sub_resource type="Theme" id=1]
[node name="Export" type="GraphNode" index="0"]
[node name="Export" type="GraphNode"]
anchor_left = 0.0
anchor_top = 0.0
@ -33,10 +33,16 @@ slot/0/left_color = Color( 0.5, 0.5, 1, 1 )
slot/0/right_enabled = false
slot/0/right_type = 0
slot/0/right_color = Color( 0.5, 0.5, 1, 1 )
slot/1/left_enabled = false
slot/1/left_type = 0
slot/1/left_color = Color( 1, 1, 1, 1 )
slot/1/right_enabled = false
slot/1/right_type = 0
slot/1/right_color = Color( 1, 1, 1, 1 )
script = ExtResource( 1 )
_sections_unfolded = [ "Theme", "slot", "slot/0" ]
[node name="Suffix" type="LineEdit" parent="." index="0"]
[node name="resolution" type="OptionButton" parent="." index="0"]
anchor_left = 0.0
anchor_top = 0.0
@ -44,8 +50,38 @@ anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 16.0
margin_top = 24.0
margin_right = 74.0
margin_bottom = 48.0
margin_right = 126.0
margin_bottom = 44.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"
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 ]
selected = 1
_sections_unfolded = [ "Rect", "custom_constants" ]
[node name="Suffix" type="LineEdit" parent="." index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 16.0
margin_top = 44.0
margin_right = 126.0
margin_bottom = 68.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2

View File

@ -1,6 +1,7 @@
tool
extends "res://addons/procedural_material/node_base.gd"
var resolution = 1
var albedo_color
var metallic
var roughness
@ -25,7 +26,7 @@ const TEXTURE_LIST = [
func _ready():
for t in TEXTURE_LIST:
generated_textures[t.texture] = { shader=null, source=null, texture=null }
initialize_properties([ $Albedo/albedo_color, $Metallic/metallic, $Roughness/roughness, $Emission/emission_energy, $NormalMap/normal_scale, $AmbientOcclusion/ao_light_affect, $DepthMap/depth_scale ])
initialize_properties([ $resolution, $Albedo/albedo_color, $Metallic/metallic, $Roughness/roughness, $Emission/emission_energy, $NormalMap/normal_scale, $AmbientOcclusion/ao_light_affect, $DepthMap/depth_scale ])
func _rerender():
var has_textures = false
@ -97,6 +98,8 @@ func do_update_materials(material_list):
else:
m.depth_enabled = false
func export_textures(prefix, size = 1024):
func export_textures(prefix, size = null):
if size == null:
size = int(pow(2, 8+resolution))
for t in TEXTURE_LIST:
get_parent().export_texture(get_source(t.port), "%s_%s.png" % [ prefix, t.texture ], size)

View File

@ -27,7 +27,7 @@ resizable = false
selected = false
comment = false
overlay = 0
slot/0/left_enabled = true
slot/0/left_enabled = false
slot/0/left_type = 0
slot/0/left_color = Color( 0.5, 0.5, 1, 1 )
slot/0/right_enabled = false
@ -35,7 +35,7 @@ slot/0/right_type = 0
slot/0/right_color = Color( 0.5, 0.5, 1, 1 )
slot/1/left_enabled = true
slot/1/left_type = 0
slot/1/left_color = Color( 0.756863, 0.756863, 0.756863, 1 )
slot/1/left_color = Color( 0.5, 0.5, 1, 1 )
slot/1/right_enabled = false
slot/1/right_type = 0
slot/1/right_color = Color( 0.5, 0.5, 1, 1 )
@ -44,10 +44,10 @@ slot/2/left_type = 0
slot/2/left_color = Color( 0.756863, 0.756863, 0.756863, 1 )
slot/2/right_enabled = false
slot/2/right_type = 0
slot/2/right_color = Color( 0.498039, 0.498039, 1, 1 )
slot/2/right_color = Color( 0.5, 0.5, 1, 1 )
slot/3/left_enabled = true
slot/3/left_type = 0
slot/3/left_color = Color( 0.498039, 0.498039, 1, 1 )
slot/3/left_color = Color( 0.756863, 0.756863, 0.756863, 1 )
slot/3/right_enabled = false
slot/3/right_type = 0
slot/3/right_color = Color( 0.498039, 0.498039, 1, 1 )
@ -59,22 +59,27 @@ slot/4/right_type = 0
slot/4/right_color = Color( 0.498039, 0.498039, 1, 1 )
slot/5/left_enabled = true
slot/5/left_type = 0
slot/5/left_color = Color( 0.756863, 0.756863, 0.756863, 1 )
slot/5/left_color = Color( 0.498039, 0.498039, 1, 1 )
slot/5/right_enabled = false
slot/5/right_type = 0
slot/5/right_color = Color( 0.498039, 0.498039, 1, 1 )
slot/6/left_enabled = true
slot/6/left_type = 0
slot/6/left_color = Color( 0.494118, 0.494118, 1, 1 )
slot/6/left_color = Color( 0.756863, 0.756863, 0.756863, 1 )
slot/6/right_enabled = false
slot/6/right_type = 0
slot/6/right_color = Color( 0.494118, 0.494118, 1, 1 )
slot/6/right_color = Color( 0.498039, 0.498039, 1, 1 )
slot/7/left_enabled = true
slot/7/left_type = 0
slot/7/left_color = Color( 0.494118, 0.494118, 1, 1 )
slot/7/right_enabled = false
slot/7/right_type = 0
slot/7/right_color = Color( 0.494118, 0.494118, 1, 1 )
script = ExtResource( 1 )
_sections_unfolded = [ "Theme", "slot", "slot/0", "slot/1", "slot/2", "slot/5" ]
[node name="Albedo" type="HBoxContainer" parent="." index="0"]
[node name="resolution" type="OptionButton" parent="." index="0"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
@ -85,6 +90,35 @@ margin_right = 214.0
margin_bottom = 44.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"
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 ]
selected = 1
[node name="Albedo" type="HBoxContainer" parent="." index="1"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 16.0
margin_top = 44.0
margin_right = 214.0
margin_bottom = 64.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
@ -139,7 +173,7 @@ color = Color( 1, 1, 1, 1 )
edit_alpha = true
_sections_unfolded = [ "Rect", "Size Flags" ]
[node name="Metallic" type="HBoxContainer" parent="." index="1"]
[node name="Metallic" type="HBoxContainer" parent="." index="2"]
editor/display_folded = true
anchor_left = 0.0
@ -147,9 +181,9 @@ anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 16.0
margin_top = 44.0
margin_top = 65.0
margin_right = 214.0
margin_bottom = 68.0
margin_bottom = 89.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
@ -206,7 +240,7 @@ prefix = ""
suffix = ""
_sections_unfolded = [ "Rect" ]
[node name="Roughness" type="HBoxContainer" parent="." index="2"]
[node name="Roughness" type="HBoxContainer" parent="." index="3"]
editor/display_folded = true
anchor_left = 0.0
@ -214,9 +248,9 @@ anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 16.0
margin_top = 69.0
margin_top = 90.0
margin_right = 214.0
margin_bottom = 93.0
margin_bottom = 114.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
@ -273,7 +307,7 @@ prefix = ""
suffix = ""
_sections_unfolded = [ "Rect" ]
[node name="Emission" type="HBoxContainer" parent="." index="3"]
[node name="Emission" type="HBoxContainer" parent="." index="4"]
editor/display_folded = true
anchor_left = 0.0
@ -281,9 +315,9 @@ anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 16.0
margin_top = 94.0
margin_top = 115.0
margin_right = 214.0
margin_bottom = 118.0
margin_bottom = 139.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
@ -340,7 +374,7 @@ prefix = ""
suffix = ""
_sections_unfolded = [ "Rect" ]
[node name="NormalMap" type="HBoxContainer" parent="." index="4"]
[node name="NormalMap" type="HBoxContainer" parent="." index="5"]
editor/display_folded = true
anchor_left = 0.0
@ -348,9 +382,9 @@ anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 16.0
margin_top = 119.0
margin_top = 140.0
margin_right = 214.0
margin_bottom = 143.0
margin_bottom = 164.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
@ -407,7 +441,7 @@ prefix = ""
suffix = ""
_sections_unfolded = [ "Rect" ]
[node name="AmbientOcclusion" type="HBoxContainer" parent="." index="5"]
[node name="AmbientOcclusion" type="HBoxContainer" parent="." index="6"]
editor/display_folded = true
anchor_left = 0.0
@ -415,9 +449,9 @@ anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 16.0
margin_top = 144.0
margin_top = 165.0
margin_right = 214.0
margin_bottom = 168.0
margin_bottom = 189.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
@ -474,7 +508,7 @@ prefix = ""
suffix = ""
_sections_unfolded = [ "Rect" ]
[node name="DepthMap" type="HBoxContainer" parent="." index="6"]
[node name="DepthMap" type="HBoxContainer" parent="." index="7"]
editor/display_folded = true
anchor_left = 0.0
@ -482,9 +516,9 @@ anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 16.0
margin_top = 169.0
margin_top = 190.0
margin_right = 214.0
margin_bottom = 193.0
margin_bottom = 214.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1