You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Fix incorrect setup of boolean uniform instances
This commit is contained in:
@@ -1454,8 +1454,23 @@ void RendererSceneCull::instance_geometry_set_shader_parameter(RID p_instance, c
|
||||
} else {
|
||||
E->value.value = p_value;
|
||||
if (E->value.index >= 0 && instance->instance_allocated_shader_uniforms) {
|
||||
int flags_count = 0;
|
||||
if (E->value.info.hint == PROPERTY_HINT_FLAGS) {
|
||||
// A small hack to detect boolean flags count and prevent overhead.
|
||||
switch (E->value.info.hint_string.length()) {
|
||||
case 3: // "x,y"
|
||||
flags_count = 1;
|
||||
break;
|
||||
case 5: // "x,y,z"
|
||||
flags_count = 2;
|
||||
break;
|
||||
case 7: // "x,y,z,w"
|
||||
flags_count = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//update directly
|
||||
RSG::material_storage->global_shader_parameters_instance_update(p_instance, E->value.index, p_value);
|
||||
RSG::material_storage->global_shader_parameters_instance_update(p_instance, E->value.index, p_value, flags_count);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3889,7 +3904,22 @@ void RendererSceneCull::_update_dirty_instance(Instance *p_instance) {
|
||||
|
||||
for (const KeyValue<StringName, Instance::InstanceShaderParameter> &E : p_instance->instance_shader_uniforms) {
|
||||
if (E.value.value.get_type() != Variant::NIL) {
|
||||
RSG::material_storage->global_shader_parameters_instance_update(p_instance->self, E.value.index, E.value.value);
|
||||
int flags_count = 0;
|
||||
if (E.value.info.hint == PROPERTY_HINT_FLAGS) {
|
||||
// A small hack to detect boolean flags count and prevent overhead.
|
||||
switch (E.value.info.hint_string.length()) {
|
||||
case 3: // "x,y"
|
||||
flags_count = 1;
|
||||
break;
|
||||
case 5: // "x,y,z"
|
||||
flags_count = 2;
|
||||
break;
|
||||
case 7: // "x,y,z,w"
|
||||
flags_count = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
RSG::material_storage->global_shader_parameters_instance_update(p_instance->self, E.value.index, E.value.value, flags_count);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user