Skip to content

Commit

Permalink
Shadow volume culling and tighter shadow caster culling
Browse files Browse the repository at this point in the history
Existing shadow caster culling using the BVH takes no account of the camera. This PR adds the highly encapsulated class VisualServerLightCuller which can cut down the casters in the shadow volume to only those which can cast shadows on the camera frustum.

This is used to:
* More accurately defer dirty updates to shadows when the shadow volume does not intersect the camera frustum.
* Tighter cull shadow casters to the view frustum.

Lights dirty state is now automatically managed:
* Continuous (tighter caster culling)
* Static (all casters are rendered)
  • Loading branch information
lawnjelly committed Nov 14, 2023
1 parent e236747 commit 8ca631a
Show file tree
Hide file tree
Showing 6 changed files with 1,416 additions and 18 deletions.
9 changes: 9 additions & 0 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1800,13 +1800,22 @@
<member name="rendering/quality/shadow_atlas/size.mobile" type="int" setter="" getter="" default="2048">
Lower-end override for [member rendering/quality/shadow_atlas/size] on mobile devices, due to performance concerns or driver support.
</member>
<member name="rendering/quality/shadows/caster_culling" type="bool" setter="" getter="" default="true">
If [code]true[/code], items that cannot cast shadows into the view frustum will not be rendered into shadow maps.
This can increase performance.
[b]Note:[/b] This setting only takes effect when [member rendering/quality/shadows/light_culling] is also [code]true[/code].
</member>
<member name="rendering/quality/shadows/filter_mode" type="int" setter="" getter="" default="1">
Shadow filter mode. Higher-quality settings result in smoother shadows that flicker less when moving. "Disabled" is the fastest option, but also has the lowest quality. "PCF5" is smoother but is also slower. "PCF13" is the smoothest option, but is also the slowest.
[b]Note:[/b] When using the GLES2 backend, the "PCF13" option actually uses 16 samples to emulate linear filtering in the shader. This results in a shadow appearance similar to the one produced by the GLES3 backend.
</member>
<member name="rendering/quality/shadows/filter_mode.mobile" type="int" setter="" getter="" default="0">
Lower-end override for [member rendering/quality/shadows/filter_mode] on mobile devices, due to performance concerns or driver support.
</member>
<member name="rendering/quality/shadows/light_culling" type="bool" setter="" getter="" default="true">
If [code]true[/code], prevents shadows from rendering for lights that do not intersect the view frustum.
This can increase performance.
</member>
<member name="rendering/quality/skinning/force_software_skinning" type="bool" setter="" getter="" default="false">
Forces [MeshInstance] to always perform skinning on the CPU (applies to both GLES2 and GLES3).
See also [member rendering/quality/skinning/software_skinning_fallback].
Expand Down
4 changes: 1 addition & 3 deletions scene/main/scene_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,7 @@ bool SceneTree::idle(float p_time) {

#endif

if (_physics_interpolation_enabled) {
VisualServer::get_singleton()->pre_draw(true);
}
VisualServer::get_singleton()->pre_draw(true);

return _quit;
}
Expand Down
Loading

0 comments on commit 8ca631a

Please sign in to comment.