Skip to content

Commit

Permalink
Fix shader params missing in headless export
Browse files Browse the repository at this point in the history
Previously, requesting the shader parameter list from the rendering
server would be a no-op when using the dummy rendering server. This
would cause the params to be lost during a headless export.

This change uses the param_cache of the ShaderMaterial instead of
the rendering server to avoid this issue.

Addresses #66842
  • Loading branch information
cgsdev0 committed Jul 18, 2023
1 parent 4dcf2c5 commit af815d1
Showing 1 changed file with 21 additions and 1 deletion.
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

0 comments on commit af815d1

Please sign in to comment.