Merge pull request #43506 from QbieShay/fix-depth-sort

[3.x] VisualServer now sorts based on AABB position
This commit is contained in:
Rémi Verschelde 2021-05-23 01:23:46 +02:00 committed by GitHub
commit 4100a80502
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2096,8 +2096,8 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
geom->gi_probes_dirty = false;
}
ins->depth = near_plane.distance_to(ins->transform.origin);
Vector3 aabb_center = ins->transformed_aabb.position + (ins->transformed_aabb.size * 0.5);
ins->depth = near_plane.distance_to(aabb_center);
ins->depth_layer = CLAMP(int(ins->depth * 16 / z_far), 0, 15);
}