mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
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.
This commit is contained in:
parent
29b3d9e9e5
commit
691854d589
8 changed files with 129 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue