Skip to content

Commit

Permalink
Merge pull request #60381 from clayjohn/3.x-sorting
Browse files Browse the repository at this point in the history
[3.x] Sort based on camera position when using perspective camera
  • Loading branch information
akien-mga authored Apr 26, 2022
2 parents ab4bbdd + 76ff41c commit d063bc4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion servers/visual/visual_server_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3171,7 +3171,11 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca

if (((1 << ins->base_type) & VS::INSTANCE_GEOMETRY_MASK) && ins->visible && ins->cast_shadows != VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
Vector3 aabb_center = ins->transformed_aabb.position + (ins->transformed_aabb.size * 0.5);
ins->depth = near_plane.distance_to(aabb_center);
if (p_cam_orthogonal) {
ins->depth = near_plane.distance_to(aabb_center);
} else {
ins->depth = p_cam_transform.origin.distance_to(aabb_center);
}
ins->depth_layer = CLAMP(int(ins->depth * 16 / z_far), 0, 15);
}
}
Expand Down

0 comments on commit d063bc4

Please sign in to comment.