diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-01-22 22:02:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-22 22:02:09 +0100 |
commit | 37897dba80ae88785ca1cc7e0a717a6b15081a5b (patch) | |
tree | a5f03261aac00dd417b6e3ce731527da078d6e26 /servers/visual | |
parent | 91b0be18dcc3ba3b1ecd35e8a7e416883776cf7b (diff) | |
parent | eaf8e5ce52331d05ee117c21e114ab0990dd3a9b (diff) |
Merge pull request #35406 from lawnjelly/ortho-shadow
Replace CameraMatrix::get_viewport_size with get_viewport_half_extents, shadow culling with ortho camera and other affected issues
Diffstat (limited to 'servers/visual')
-rw-r--r-- | servers/visual/visual_server_scene.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 409a814b3b..f5767e93a2 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -1400,9 +1400,9 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons if (p_cam_orthogonal) { - float w, h; - p_cam_projection.get_viewport_size(w, h); - camera_matrix.set_orthogonal(w, aspect, distances[(i == 0 || !overlap) ? i : i - 1], distances[i + 1], false); + Vector2 vp_he = p_cam_projection.get_viewport_half_extents(); + + camera_matrix.set_orthogonal(vp_he.y * 2.0, aspect, distances[(i == 0 || !overlap) ? i : i - 1], distances[i + 1], false); } else { float fov = p_cam_projection.get_fov(); @@ -2090,8 +2090,8 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca float zn = p_cam_projection.get_z_near(); Plane p(cam_xf.origin + cam_xf.basis.get_axis(2) * -zn, -cam_xf.basis.get_axis(2)); //camera near plane - float vp_w, vp_h; //near plane size in screen coordinates - p_cam_projection.get_viewport_size(vp_w, vp_h); + // near plane half width and height + Vector2 vp_half_extents = p_cam_projection.get_viewport_half_extents(); switch (VSG::storage->light_get_type(ins->base)) { @@ -2117,7 +2117,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca } float screen_diameter = points[0].distance_to(points[1]) * 2; - coverage = screen_diameter / (vp_w + vp_h); + coverage = screen_diameter / (vp_half_extents.x + vp_half_extents.y); } break; case VS::LIGHT_SPOT: { @@ -2146,7 +2146,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca } float screen_diameter = points[0].distance_to(points[1]) * 2; - coverage = screen_diameter / (vp_w + vp_h); + coverage = screen_diameter / (vp_half_extents.x + vp_half_extents.y); } break; default: { |