diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-12-23 09:47:24 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-12-23 09:47:24 +0100 |
commit | 1cab6c91e97b6371247afaf4de016ef6b83efcb0 (patch) | |
tree | 819f6ab8ebf5b1d323202475074574d4edfbfa2b /servers/rendering/renderer_rd/forward_clustered | |
parent | ae4c025da9598f3d9efbda8008d4ac7fb5b3ba63 (diff) | |
parent | 6f4f38db07c901a8b7dc74ad871af98030336031 (diff) |
Merge pull request #69998 from BastiaanOlij/sorting-pivot-4
Added options for sorting transparent objects (port of PR #63040)
Diffstat (limited to 'servers/rendering/renderer_rd/forward_clustered')
-rw-r--r-- | servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp | 14 |
1 files changed, 12 insertions, 2 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 0cfe639480..608f7ff958 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp @@ -831,8 +831,18 @@ void RenderForwardClustered::_fill_render_list(RenderListType p_render_list, con for (int i = 0; i < (int)p_render_data->instances->size(); i++) { GeometryInstanceForwardClustered *inst = static_cast<GeometryInstanceForwardClustered *>((*p_render_data->instances)[i]); - Vector3 support_min = inst->transformed_aabb.get_support(-near_plane.normal); - inst->depth = near_plane.distance_to(support_min); + Vector3 center = inst->transform.origin; + if (p_render_data->scene_data->cam_orthogonal) { + if (inst->use_aabb_center) { + center = inst->transformed_aabb.get_support(-near_plane.normal); + } + inst->depth = near_plane.distance_to(center) - inst->sorting_offset; + } else { + if (inst->use_aabb_center) { + center = inst->transformed_aabb.position + (inst->transformed_aabb.size * 0.5); + } + inst->depth = p_render_data->scene_data->cam_transform.origin.distance_to(center) - inst->sorting_offset; + } uint32_t depth_layer = CLAMP(int(inst->depth * 16 / z_max), 0, 15); uint32_t flags = inst->base_flags; //fill flags if appropriate |