summaryrefslogtreecommitdiff
path: root/servers/rendering
diff options
context:
space:
mode:
authorclayjohn <claynjohn@gmail.com>2023-04-12 14:41:17 -0700
committerYuri Sizov <yuris@humnom.net>2023-04-24 16:52:24 +0200
commitad582cf0b163a8c15ba6a372ee76e0133213976c (patch)
tree5ee432e3ee2480463875c906e40fdc1de0c15756 /servers/rendering
parent410b503aace744ba1ea5b1f7a67d0d8600258481 (diff)
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 (cherry picked from commit 29edd277e4a45c9f84a9f5291087e671b2169191)
Diffstat (limited to 'servers/rendering')
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp16
-rw-r--r--servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp16
2 files changed, 16 insertions, 16 deletions
diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
index 91789201c6..c7d85a3bbf 100644
--- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
+++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
@@ -721,6 +721,14 @@ void RenderForwardClustered::_fill_instance_data(RenderListType p_render_list, i
if (inst->store_transform_cache) {
RendererRD::MaterialStorage::store_transform(inst->transform, instance_data.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 {
RendererRD::MaterialStorage::store_transform(Transform3D(), instance_data.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[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();
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) {
diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
index 6bfbc2e0a7..b9edc46aee 100644
--- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
+++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
@@ -2060,17 +2060,17 @@ void RenderForwardMobile::_render_list_template(RenderingDevice::DrawListID p_dr
if (inst->store_transform_cache) {
RendererRD::MaterialStorage::store_transform(inst->transform, push_constant.transform);
- } else {
- 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]);
+ // 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 {
+ RendererRD::MaterialStorage::store_transform(Transform3D(), push_constant.transform);
+ }
push_constant.flags = inst->flags_cache;
push_constant.gi_offset = inst->gi_offset_cache;