diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 2b44043faf..1faecfd4d0 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1170,12 +1170,17 @@ void RasterizerSceneGLES3::_fill_render_list(RenderListType p_render_list, const for (int i = 0; i < (int)p_render_data->instances->size(); i++) { GeometryInstanceGLES3 *inst = static_cast<GeometryInstanceGLES3 *>((*p_render_data->instances)[i]); + Vector3 center = inst->transform.origin; if (p_render_data->cam_orthogonal) { - Vector3 support_min = inst->transformed_aabb.get_support(-near_plane.normal); - inst->depth = near_plane.distance_to(support_min); + 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 { - Vector3 aabb_center = inst->transformed_aabb.position + (inst->transformed_aabb.size * 0.5); - inst->depth = p_render_data->cam_transform.origin.distance_to(aabb_center); + if (inst->use_aabb_center) { + center = inst->transformed_aabb.position + (inst->transformed_aabb.size * 0.5); + } + inst->depth = p_render_data->cam_transform.origin.distance_to(center) - inst->sorting_offset; } uint32_t depth_layer = CLAMP(int(inst->depth * 16 / z_max), 0, 15); |