Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing shader params in headless export #76121

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion scene/resources/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,30 @@ bool ShaderMaterial::_get(const StringName &p_name, Variant &r_ret) const {
return false;
}

static bool is_headless_exporting() {
#ifdef TOOLS_ENABLED
if (OS::get_singleton()->get_cmdline_args().find("--headless")) {
if (OS::get_singleton()->get_cmdline_args().find("--export")) {
return true;
}
}
#endif
return false;
}

void ShaderMaterial::_get_property_list(List<PropertyInfo> *p_list) const {
if (!shader.is_null()) {
List<PropertyInfo> list;
shader->get_shader_uniform_list(&list, true);

static const bool is_headless_export = is_headless_exporting();
if (is_headless_export) {
shader->get_shader_uniform_list(&list, true);
} else {
// Hacky solution to make --headless exports include shader parameters.
for (const KeyValue<StringName, Variant> &P : param_cache) {
list.push_back(PropertyInfo(P.value.get_type(), P.key));
}
}

HashMap<String, HashMap<String, List<PropertyInfo>>> groups;
{
Expand Down
Loading