Skip to content

Commit 1586b88

Browse files
committed
Merge branch 'master' into alpha-association-conversion
2 parents 7e872d1 + e0a4250 commit 1586b88

406 files changed

Lines changed: 3715 additions & 1490 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Build Export Templates (Single Job)
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
GODOT_VERSION: 4.5.1
8+
GODOT_SUB: stable
9+
GODOT_DOWNLOAD_DIR: https://github.com/godotengine/godot-builds/releases/download/${GODOT_VERSION}-${GODOT_SUB}
10+
SCONSFLAGS: verbose=yes warnings=all use_lto=yes
11+
12+
jobs:
13+
build_templates:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout current repo
18+
uses: actions/checkout@v4
19+
with:
20+
path: material-maker
21+
22+
- name: Clone latest stable Godot source into ./godot
23+
run: |
24+
git clone --depth 1 --branch ${GODOT_VERSION}-${GODOT_SUB} https://github.com/godotengine/godot.git godot
25+
cd godot
26+
patch -p1 < ../material-maker/material_maker/misc/mm.patch
27+
28+
- name: Install dependencies
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get update
32+
sudo apt-get install -y build-essential scons pkg-config libx11-dev \
33+
libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu1-mesa-dev \
34+
libasound2-dev libpulse-dev libudev-dev libxi-dev libxrandr-dev \
35+
libwayland-dev
36+
sudo apt-get install -y build-essential scons pkg-config python3 \
37+
mingw-w64 clang zip unzip curl git cmake
38+
sudo update-alternatives --install /usr/bin/x86_64-w64-mingw32-g++ \
39+
x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix 100
40+
sudo update-alternatives --install /usr/bin/x86_64-w64-mingw32-gcc \
41+
x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix 100
42+
sudo update-alternatives --set x86_64-w64-mingw32-g++ \
43+
/usr/bin/x86_64-w64-mingw32-g++-posix
44+
sudo update-alternatives --set x86_64-w64-mingw32-gcc \
45+
/usr/bin/x86_64-w64-mingw32-gcc-posix
46+
47+
- name: Cache SCons build artifacts
48+
uses: actions/cache@v3
49+
with:
50+
path: |
51+
godot/.sconsign.dblite
52+
godot/bin/
53+
key: ${{ runner.os }}-godot-${{ hashFiles('godot/**/*.cpp', 'godot/**/*.h', 'godot/SConstruct', 'godot/SCsub') }}
54+
restore-keys: |
55+
${{ runner.os }}-godot-
56+
57+
- name: Build export templates (Linux)
58+
run: |
59+
cd godot
60+
scons platform=linuxbsd target=template_release tools=no production=yes
61+
cd ..
62+
63+
- name: Build export templates (Windows)
64+
run: |
65+
cd godot
66+
scons platform=windows target=template_release arch=x86_64 tools=no production=yes
67+
cd ..
68+
69+
- name: Package Linux build
70+
run: |
71+
mkdir -p templates_linux
72+
cp godot/bin/*linuxbsd* templates_linux/
73+
(cd templates_linux && zip -9 -r ../export_templates_linux.zip .)
74+
75+
- name: Package Windows build
76+
run: |
77+
mkdir -p templates_windows
78+
cp godot/bin/*windows* templates_windows/
79+
(cd templates_windows && zip -9 -r ../export_templates_windows.zip .)
80+
81+
- name: Upload Linux artifact
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: linux-templates
85+
path: export_templates_linux.zip
86+
87+
- name: Upload Windows artifact
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: windows-templates
91+
path: export_templates_windows.zip
92+
build_templates_macos:
93+
runs-on: macos-latest
94+
95+
steps:
96+
- name: Checkout current repo
97+
uses: actions/checkout@v4
98+
with:
99+
path: material-maker
100+
101+
- name: Clone latest stable Godot source into ./godot
102+
run: |
103+
git clone --depth 1 --branch ${GODOT_VERSION}-${GODOT_SUB} https://github.com/godotengine/godot.git godot
104+
cd godot
105+
patch -p1 < ../material-maker/material_maker/misc/mm.patch
106+
107+
- name: Install dependencies
108+
run: |
109+
brew install scons
110+
./godot/misc/scripts/install_vulkan_sdk_macos.sh
111+
112+
- name: Cache SCons build artifacts
113+
uses: actions/cache@v3
114+
with:
115+
path: |
116+
godot/.sconsign.dblite
117+
godot/bin/
118+
key: ${{ runner.os }}-godot-${{ hashFiles('godot/**/*.cpp', 'godot/**/*.h', 'godot/SConstruct', 'godot/SCsub') }}
119+
restore-keys: |
120+
${{ runner.os }}-godot-
121+
122+
- name: Build export templates (MacOS)
123+
run: |
124+
cd godot
125+
scons platform=macos arch=x86_64 target=template_release tools=no production=yes
126+
scons platform=macos arch=arm64 target=template_release tools=no production=yes generate_bundle=yes
127+
cp ./bin/godot_macos.zip ../export_templates_macos.zip
128+
129+
- name: Upload MacOS artifact
130+
uses: actions/upload-artifact@v4
131+
with:
132+
name: macos-templates
133+
path: export_templates_macos.zip

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
Copyright (c) 2018-2025 Rodolphe Suescun and contributors
3+
Copyright (c) 2018-present Rodolphe Suescun and contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Translation files can be installed using the **Install** button in the **Prefere
5555

5656
## License
5757

58-
Copyright (c) 2018-2025 Rodolphe Suescun and contributors
58+
Copyright (c) 2018-present Rodolphe Suescun and contributors
5959

6060
Unless otherwise specified, files in this repository are licensed under the
6161
MIT license. See [LICENSE.md](LICENSE.md) for more information.

addons/material_maker/engine/dependencies.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
extends Node
22

33

4+
signal updated
5+
46
class Buffer:
57
enum {
68
Invalidated,
@@ -208,6 +210,7 @@ func do_update():
208210
if invalidated_buffers == 0:
209211
emit_signal("render_queue_empty")
210212
updating = false
213+
updated.emit()
211214

212215
func get_render_queue_size() -> int:
213216
var invalidated_buffers : int = 0

addons/material_maker/engine/nodes/gen_image.gd

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ func set_parameter(n : String, v) -> void:
5555
super.set_parameter(n, v)
5656
if n == "image" and FileAccess.file_exists(v):
5757
filetime = get_filetime(v)
58-
var image : Image = Image.load_from_file(v)
58+
var image : Image = Image.new()
59+
if v.get_extension() == "dds":
60+
# load_from_file does not work with dds, see godot issue #113063
61+
image.load_dds_from_buffer(FileAccess.get_file_as_bytes(v))
62+
else:
63+
image = Image.load_from_file(v)
5964
if image != null:
6065
var image_texture : ImageTexture = ImageTexture.create_from_image(image)
6166
texture.set_texture(image_texture)
@@ -67,7 +72,10 @@ func _on_timeout() -> void:
6772
if filetime != new_filetime:
6873
filetime = new_filetime
6974
var image : Image = Image.new()
70-
image.load(file_path)
75+
if file_path.get_extension() == "dds":
76+
image.load_dds_from_buffer(FileAccess.get_file_as_bytes(file_path))
77+
else:
78+
image.load(file_path)
7179
var image_texture : ImageTexture = ImageTexture.create_from_image(image)
7280
if image_texture:
7381
texture.set_texture(image_texture)

addons/material_maker/engine/nodes/gen_iterate_buffer.gd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ func on_dep_update_buffer(buffer_name : String) -> bool:
181181

182182
is_rendering = true
183183

184-
var shader_compute : MMShaderCompute = shader_computes[0] if current_iteration == 0 else shader_computes[1]
184+
var first_iteration : bool = ( current_iteration == 0 )
185+
var shader_compute : MMShaderCompute = shader_computes[0] if first_iteration else shader_computes[1]
185186
# Calculate iteration count
186187
var iterations = calculate_float_parameter("iterations")
187188
if iterations.has("used_named_parameters"):
@@ -231,7 +232,7 @@ func on_dep_update_buffer(buffer_name : String) -> bool:
231232
else:
232233
set_current_iteration(current_iteration+1)
233234

234-
235+
mm_deps.dependency_update(buffer_name_init_input if first_iteration else buffer_name_loop_input, texture, true)
235236
if current_iteration > iterations:
236237
mm_deps.dependency_update(buffer_name_output, texture, true)
237238
else:

addons/material_maker/engine/nodes/gen_material.gd

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var update_again : bool = false
1515
var preview_material : ShaderMaterial = null
1616
var preview_parameters : Dictionary = {}
1717
var preview_textures = {}
18-
var preview_texture_dependencies = {}
18+
var preview_texture_dependencies : Dictionary[String, MMTexture] = {}
1919

2020
var external_previews : Dictionary[Node, Array] = {}
2121
var export_output_def : Dictionary
@@ -134,7 +134,7 @@ func on_dep_update_value(buffer_name, parameter_name, value) -> bool:
134134
if value is MMTexture:
135135
var texture = await value.get_texture()
136136
p.set_shader_parameter(parameter_name, texture)
137-
preview_texture_dependencies[parameter_name] = texture
137+
preview_texture_dependencies[parameter_name] = value
138138
else:
139139
p.set_shader_parameter(parameter_name, value)
140140
else:
@@ -200,8 +200,8 @@ func update() -> void:
200200
for u in result.uniforms:
201201
if u.value:
202202
if u.type == "sampler2D":
203+
preview_texture_dependencies[u.name] = u.value
203204
var texture = await u.value.get_texture()
204-
preview_texture_dependencies[u.name] = texture
205205
preview_material.set_shader_parameter(u.name, texture)
206206
else:
207207
preview_material.set_shader_parameter(u.name, u.value)
@@ -647,7 +647,7 @@ func get_connections_and_parameters_context() -> Dictionary:
647647
context["$(param:"+p.name+".a)"] = str(value.a)
648648
return context
649649

650-
func export_material(prefix : String, profile : String, size : int = 0) -> void:
650+
func export_material(prefix : String, profile : String, size : int = 0, command_line : bool = false) -> void:
651651
reset_uids()
652652
if size == 0:
653653
size = get_image_size()
@@ -680,7 +680,7 @@ func export_material(prefix : String, profile : String, size : int = 0) -> void:
680680
overwrite_files.push_back(f)
681681
continue
682682
exported_files.push_back(f)
683-
if ! overwrite_files.is_empty():
683+
if not command_line and not overwrite_files.is_empty():
684684
var dialog = load("res://material_maker/windows/accept_dialog/accept_dialog.tscn").instantiate()
685685
dialog.dialog_text = "Overwrite existing files?"
686686
for f in overwrite_files:
@@ -692,15 +692,18 @@ func export_material(prefix : String, profile : String, size : int = 0) -> void:
692692
if result == "ok":
693693
exported_files.append_array(overwrite_files)
694694
var progress_dialog = null
695-
var progress_dialog_scene = load("res://material_maker/windows/progress_window/progress_window.tscn")
696-
if progress_dialog_scene != null:
697-
progress_dialog = progress_dialog_scene.instantiate()
698-
var dim_color_rect = ColorRect.new()
699-
dim_color_rect.modulate = Color(0.05, 0.05, 0.05, 0.5)
700-
mm_globals.main_window.add_child(dim_color_rect)
701-
get_tree().get_root().add_child(progress_dialog)
702-
progress_dialog.set_text("Exporting material")
703-
progress_dialog.set_progress(0)
695+
var dim_color_rect = null
696+
if not command_line:
697+
var progress_dialog_scene = load("res://material_maker/windows/progress_window/progress_window.tscn")
698+
if progress_dialog_scene != null:
699+
progress_dialog = progress_dialog_scene.instantiate()
700+
dim_color_rect = ColorRect.new()
701+
dim_color_rect.modulate = Color(0.05, 0.05, 0.05, 0.5)
702+
mm_globals.main_window.add_child(dim_color_rect)
703+
if progress_dialog:
704+
get_tree().get_root().add_child(progress_dialog)
705+
progress_dialog.set_text("Exporting material")
706+
progress_dialog.set_progress(0)
704707
var total_files : int = 0
705708
for f in exported_files:
706709
match f.type:
@@ -711,6 +714,7 @@ func export_material(prefix : String, profile : String, size : int = 0) -> void:
711714
var processed_files = 0
712715
var error_files = 0
713716
for f in exported_files:
717+
#print("Exporting ", f)
714718
var e: Error = OK
715719
match f.type:
716720
"texture":
@@ -719,7 +723,7 @@ func export_material(prefix : String, profile : String, size : int = 0) -> void:
719723
var render_queue_size : int = mm_deps.get_render_queue_size()
720724
while true:
721725
mm_deps.update()
722-
await get_tree().process_frame
726+
await mm_deps.updated
723727
if render_queue_size == mm_deps.get_render_queue_size():
724728
break
725729
render_queue_size = mm_deps.get_render_queue_size()
@@ -744,14 +748,16 @@ func export_material(prefix : String, profile : String, size : int = 0) -> void:
744748
e = FAILED
745749
processed_files += 1
746750
error_files += 1
747-
progress_dialog.set_progress(float(processed_files)/float(total_files))
751+
if progress_dialog:
752+
progress_dialog.set_progress(float(processed_files)/float(total_files))
748753
continue
749754
var result : MMTexture = await render_output_to_texture(output_index, Vector2i(size, size))
750755
e = await result.save_to_file(file_name)
751756
if e != OK:
752757
error_files += 1
753758
processed_files += 1
754-
progress_dialog.set_progress(float(processed_files)/float(total_files))
759+
if progress_dialog:
760+
progress_dialog.set_progress(float(processed_files)/float(total_files))
755761
"template":
756762
var file_export_context = export_context.duplicate()
757763
if f.has("file_params"):
@@ -762,26 +768,37 @@ func export_material(prefix : String, profile : String, size : int = 0) -> void:
762768
if e != OK:
763769
error_files += 1
764770
processed_files += 1
765-
progress_dialog.set_progress(float(processed_files)/float(total_files))
771+
if progress_dialog:
772+
progress_dialog.set_progress(float(processed_files)/float(total_files))
766773
"buffers":
767-
var index : int = 1
774+
# Wait until the render queue is empty
768775
if mm_deps.get_render_queue_size() > 0:
769-
await mm_deps.render_queue_empty
776+
var render_queue_size : int = mm_deps.get_render_queue_size()
777+
while true:
778+
mm_deps.update()
779+
await mm_deps.updated
780+
if render_queue_size == mm_deps.get_render_queue_size():
781+
break
782+
render_queue_size = mm_deps.get_render_queue_size()
783+
var index : int = 1
770784
for t in preview_texture_dependencies.keys():
771785
var file_name = subst_string(f.file_name, export_context)
772786
file_name = file_name.replace("$(buffer_index)", str(index))
773-
var image : Image = preview_texture_dependencies[t].get_image()
787+
var texture : Texture2D = await preview_texture_dependencies[t].get_texture()
788+
var image : Image = texture.get_image()
774789
if image:
775790
image.convert(Image.FORMAT_RGBA8)
776791
e = image.save_png(file_name)
777792
if e != OK:
778793
error_files += 1
779794
else:
780795
print("No image for texture file ", file_name)
796+
print(preview_texture_dependencies[t])
781797
error_files += 1
782798
index += 1
783799
processed_files += 1
784-
progress_dialog.set_progress(float(processed_files)/float(total_files))
800+
if progress_dialog:
801+
progress_dialog.set_progress(float(processed_files)/float(total_files))
785802
"buffer_templates":
786803
var index : int = 1
787804
for t in preview_texture_dependencies.keys():
@@ -797,15 +814,20 @@ func export_material(prefix : String, profile : String, size : int = 0) -> void:
797814
error_files += 1
798815
index += 1
799816
processed_files += 1
800-
progress_dialog.set_progress(float(processed_files)/float(total_files))
817+
if progress_dialog:
818+
progress_dialog.set_progress(float(processed_files)/float(total_files))
801819
if progress_dialog != null:
802820
progress_dialog.queue_free()
821+
if dim_color_rect != null:
803822
dim_color_rect.queue_free()
804823
if error_files == 0:
805824
mm_globals.set_tip_text("Files succesfully exported as \"%s\"" % prefix, 5, 1)
806825
return
807826
if error_files >= total_files:
808-
mm_globals.main_window.accept_dialog("Could not export files to \"%s\"" % prefix.get_base_dir(), false, true)
827+
if command_line:
828+
print("Could not export files to \"%s\"" % prefix.get_base_dir())
829+
else:
830+
mm_globals.main_window.accept_dialog("Could not export files to \"%s\"" % prefix.get_base_dir(), false, true)
809831
return
810832
if error_files < total_files:
811833
mm_globals.set_tip_text("%d errors encountered when exporting files" % error_files, 5, 1)

0 commit comments

Comments
 (0)