summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2023-02-18 14:56:41 +0100
committerGitHub <noreply@github.com>2023-02-18 14:56:41 +0100
commit1f4f73f8602f61ef43d3dc0b99bedd1614e48283 (patch)
tree0c21adfeae606964b0264e5a5bf0561848e08b93
parente9c7b8d2246bd0797af100808419c994fa43a9d2 (diff)
parent34fd128723e3dd4eff0f3d2aaeddd13ff5c6bcad (diff)
Merge pull request #73552 from reduz/fix-direct-shader-param-assign
Fix shader parameter assign
-rw-r--r--scene/resources/material.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 15fe25d062..2627898f5f 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -369,7 +369,15 @@ void ShaderMaterial::set_shader_parameter(const StringName &p_param, const Varia
param_cache.erase(p_param);
RS::get_singleton()->material_set_param(_get_material(), p_param, Variant());
} else {
- param_cache[p_param] = p_value;
+ Variant *v = param_cache.getptr(p_param);
+ if (!v) {
+ // Never assigned, also update the remap cache.
+ remap_cache["shader_parameter/" + p_param.operator String()] = p_param;
+ param_cache.insert(p_param, p_value);
+ } else {
+ *v = p_value;
+ }
+
if (p_value.get_type() == Variant::OBJECT) {
RID tex_rid = p_value;
if (tex_rid == RID()) {