mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 20:23:53 +00:00
Don't store instance transform in RD 3D renderer unless requested
Previously, when using doubles builds of the engine, instance transform was stored no matter what which caused world space particles to accumulate the instance transform twice
This commit is contained in:
parent
d4dad2b2f8
commit
29edd277e4
@ -721,6 +721,14 @@ void RenderForwardClustered::_fill_instance_data(RenderListType p_render_list, i
|
|||||||
if (inst->store_transform_cache) {
|
if (inst->store_transform_cache) {
|
||||||
RendererRD::MaterialStorage::store_transform(inst->transform, instance_data.transform);
|
RendererRD::MaterialStorage::store_transform(inst->transform, instance_data.transform);
|
||||||
RendererRD::MaterialStorage::store_transform(inst->prev_transform, instance_data.prev_transform);
|
RendererRD::MaterialStorage::store_transform(inst->prev_transform, instance_data.prev_transform);
|
||||||
|
|
||||||
|
#ifdef REAL_T_IS_DOUBLE
|
||||||
|
// Split the origin into two components, the float approximation and the missing precision
|
||||||
|
// In the shader we will combine these back together to restore the lost precision.
|
||||||
|
RendererRD::MaterialStorage::split_double(inst->transform.origin.x, &instance_data.transform[12], &instance_data.transform[3]);
|
||||||
|
RendererRD::MaterialStorage::split_double(inst->transform.origin.y, &instance_data.transform[13], &instance_data.transform[7]);
|
||||||
|
RendererRD::MaterialStorage::split_double(inst->transform.origin.z, &instance_data.transform[14], &instance_data.transform[11]);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
RendererRD::MaterialStorage::store_transform(Transform3D(), instance_data.transform);
|
RendererRD::MaterialStorage::store_transform(Transform3D(), instance_data.transform);
|
||||||
RendererRD::MaterialStorage::store_transform(Transform3D(), instance_data.prev_transform);
|
RendererRD::MaterialStorage::store_transform(Transform3D(), instance_data.prev_transform);
|
||||||
@ -735,14 +743,6 @@ void RenderForwardClustered::_fill_instance_data(RenderListType p_render_list, i
|
|||||||
instance_data.lightmap_uv_scale[2] = inst->lightmap_uv_scale.size.x;
|
instance_data.lightmap_uv_scale[2] = inst->lightmap_uv_scale.size.x;
|
||||||
instance_data.lightmap_uv_scale[3] = inst->lightmap_uv_scale.size.y;
|
instance_data.lightmap_uv_scale[3] = inst->lightmap_uv_scale.size.y;
|
||||||
|
|
||||||
#ifdef REAL_T_IS_DOUBLE
|
|
||||||
// Split the origin into two components, the float approximation and the missing precision
|
|
||||||
// In the shader we will combine these back together to restore the lost precision.
|
|
||||||
RendererRD::MaterialStorage::split_double(inst->transform.origin.x, &instance_data.transform[12], &instance_data.transform[3]);
|
|
||||||
RendererRD::MaterialStorage::split_double(inst->transform.origin.y, &instance_data.transform[13], &instance_data.transform[7]);
|
|
||||||
RendererRD::MaterialStorage::split_double(inst->transform.origin.z, &instance_data.transform[14], &instance_data.transform[11]);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool cant_repeat = instance_data.flags & INSTANCE_DATA_FLAG_MULTIMESH || inst->mesh_instance.is_valid();
|
bool cant_repeat = instance_data.flags & INSTANCE_DATA_FLAG_MULTIMESH || inst->mesh_instance.is_valid();
|
||||||
|
|
||||||
if (prev_surface != nullptr && !cant_repeat && prev_surface->sort.sort_key1 == surface->sort.sort_key1 && prev_surface->sort.sort_key2 == surface->sort.sort_key2 && inst->mirror == prev_surface->owner->mirror && repeats < RenderElementInfo::MAX_REPEATS) {
|
if (prev_surface != nullptr && !cant_repeat && prev_surface->sort.sort_key1 == surface->sort.sort_key1 && prev_surface->sort.sort_key2 == surface->sort.sort_key2 && inst->mirror == prev_surface->owner->mirror && repeats < RenderElementInfo::MAX_REPEATS) {
|
||||||
|
@ -2060,18 +2060,18 @@ void RenderForwardMobile::_render_list_template(RenderingDevice::DrawListID p_dr
|
|||||||
|
|
||||||
if (inst->store_transform_cache) {
|
if (inst->store_transform_cache) {
|
||||||
RendererRD::MaterialStorage::store_transform(inst->transform, push_constant.transform);
|
RendererRD::MaterialStorage::store_transform(inst->transform, push_constant.transform);
|
||||||
|
|
||||||
|
#ifdef REAL_T_IS_DOUBLE
|
||||||
|
// Split the origin into two components, the float approximation and the missing precision
|
||||||
|
// In the shader we will combine these back together to restore the lost precision.
|
||||||
|
RendererRD::MaterialStorage::split_double(inst->transform.origin.x, &push_constant.transform[12], &push_constant.transform[3]);
|
||||||
|
RendererRD::MaterialStorage::split_double(inst->transform.origin.y, &push_constant.transform[13], &push_constant.transform[7]);
|
||||||
|
RendererRD::MaterialStorage::split_double(inst->transform.origin.z, &push_constant.transform[14], &push_constant.transform[11]);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
RendererRD::MaterialStorage::store_transform(Transform3D(), push_constant.transform);
|
RendererRD::MaterialStorage::store_transform(Transform3D(), push_constant.transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef REAL_T_IS_DOUBLE
|
|
||||||
// Split the origin into two components, the float approximation and the missing precision
|
|
||||||
// In the shader we will combine these back together to restore the lost precision.
|
|
||||||
RendererRD::MaterialStorage::split_double(inst->transform.origin.x, &push_constant.transform[12], &push_constant.transform[3]);
|
|
||||||
RendererRD::MaterialStorage::split_double(inst->transform.origin.y, &push_constant.transform[13], &push_constant.transform[7]);
|
|
||||||
RendererRD::MaterialStorage::split_double(inst->transform.origin.z, &push_constant.transform[14], &push_constant.transform[11]);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
push_constant.flags = inst->flags_cache;
|
push_constant.flags = inst->flags_cache;
|
||||||
push_constant.gi_offset = inst->gi_offset_cache;
|
push_constant.gi_offset = inst->gi_offset_cache;
|
||||||
push_constant.layer_mask = inst->layer_mask;
|
push_constant.layer_mask = inst->layer_mask;
|
||||||
|
Loading…
Reference in New Issue
Block a user