diff options
author | lawnjelly <lawnjelly@gmail.com> | 2023-12-13 13:45:57 +0000 |
---|---|---|
committer | lawnjelly <lawnjelly@gmail.com> | 2024-04-03 12:18:45 +0100 |
commit | 691854d589e89b7bcf10cbe64c000332ef584769 (patch) | |
tree | aaa642a8d8fdce68ff13dba5618beb202ab4a0b4 /servers/rendering/renderer_scene_occlusion_cull.cpp | |
parent | 29b3d9e9e538f0aa8effc8ad8bf19a2915292a89 (diff) | |
download | redot-engine-691854d589e89b7bcf10cbe64c000332ef584769.tar.gz |
Jitter raster occlusion camera to reduce false positives.
Due to the low resolution of the occlusion buffer, small gaps between occluders can be closed and incorrectly occlude instances which should show through the gaps. To ameliorate this problem, this PR jitters the occlusion buffer over time, making it more likely an instance will be seen through a gap. This is used in conjunction with an occlusion timer per instance, to prevent instances flickering on and off rapidly.
Diffstat (limited to 'servers/rendering/renderer_scene_occlusion_cull.cpp')
-rw-r--r-- | servers/rendering/renderer_scene_occlusion_cull.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/servers/rendering/renderer_scene_occlusion_cull.cpp b/servers/rendering/renderer_scene_occlusion_cull.cpp index c4f0177c73..1f0239411a 100644 --- a/servers/rendering/renderer_scene_occlusion_cull.cpp +++ b/servers/rendering/renderer_scene_occlusion_cull.cpp @@ -43,6 +43,8 @@ const Vector3 RendererSceneOcclusionCull::HZBuffer::corners[8] = { Vector3(1, 1, 1) }; +bool RendererSceneOcclusionCull::HZBuffer::occlusion_jitter_enabled = false; + bool RendererSceneOcclusionCull::HZBuffer::is_empty() const { return sizes.is_empty(); } @@ -66,6 +68,8 @@ void RendererSceneOcclusionCull::HZBuffer::clear() { } void RendererSceneOcclusionCull::HZBuffer::resize(const Size2i &p_size) { + occlusion_buffer_size = p_size; + if (p_size == Size2i()) { clear(); return; @@ -124,6 +128,9 @@ void RendererSceneOcclusionCull::HZBuffer::resize(const Size2i &p_size) { } void RendererSceneOcclusionCull::HZBuffer::update_mips() { + // Keep this up to date as a local to be used for occlusion timers. + occlusion_frame = Engine::get_singleton()->get_frames_drawn(); + if (sizes.is_empty()) { return; } |