From 280da1702b8a2a18c33c2d3a50eab224249bc792 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 2 Sep 2026 23:08:39 +0200 Subject: [PATCH] Fix incorrect culling when drawing actors depth only --- Source/Engine/Level/Actors/AnimatedModel.cpp | 2 +- Source/Engine/Level/Actors/SplineModel.cpp | 2 +- Source/Engine/Level/Actors/StaticModel.cpp | 2 +- Source/Engine/Particles/ParticleEffect.cpp | 2 +- Source/Engine/Renderer/Renderer.cpp | 1 + Source/Engine/UI/TextRender.cpp | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/Engine/Level/Actors/AnimatedModel.cpp b/Source/Engine/Level/Actors/AnimatedModel.cpp index faa169ad3..ecd28316a 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.cpp +++ b/Source/Engine/Level/Actors/AnimatedModel.cpp @@ -1265,7 +1265,7 @@ void AnimatedModel::Draw(RenderContextBatch& renderContextBatch) auto drawState = renderContext.Buffers->GetGeometryDrawState(&GetScene()->Rendering, _sceneRenderingKey, this); SkinnedMesh::DrawInfo draw; draw.DrawModes = DrawModes; - if (drawState && renderContextBatch.Buffers->OcclusionCulling && !renderContextBatch.Buffers->OcclusionCulling->IsVisible(_box, *drawState)) + if (drawState && EnumHasAllFlags(renderContext.View.Flags, ViewFlags::OcclusionCulling) && renderContextBatch.Buffers->OcclusionCulling && !renderContextBatch.Buffers->OcclusionCulling->IsVisible(_box, *drawState)) { // Draw shadows-only (or cull) draw.DrawModes &= DrawPass::Depth; diff --git a/Source/Engine/Level/Actors/SplineModel.cpp b/Source/Engine/Level/Actors/SplineModel.cpp index b179a6a1f..3b47c920a 100644 --- a/Source/Engine/Level/Actors/SplineModel.cpp +++ b/Source/Engine/Level/Actors/SplineModel.cpp @@ -398,7 +398,7 @@ void SplineModel::Draw(RenderContextBatch& renderContextBatch) auto drawState = renderContext.Buffers->GetGeometryDrawState(&GetScene()->Rendering, _sceneRenderingKey, this); ACTOR_GET_WORLD_MATRIX(this, view, world); DrawPass drawModes = DrawModes; - if (drawState && renderContextBatch.Buffers->OcclusionCulling && !renderContextBatch.Buffers->OcclusionCulling->IsVisible(_box, *drawState)) + if (drawState && EnumHasAllFlags(renderContext.View.Flags, ViewFlags::OcclusionCulling) && renderContextBatch.Buffers->OcclusionCulling && !renderContextBatch.Buffers->OcclusionCulling->IsVisible(_box, *drawState)) { // Draw shadows-only (or cull) drawModes &= DrawPass::Depth; diff --git a/Source/Engine/Level/Actors/StaticModel.cpp b/Source/Engine/Level/Actors/StaticModel.cpp index c8cb1fbee..8c3ee65e3 100644 --- a/Source/Engine/Level/Actors/StaticModel.cpp +++ b/Source/Engine/Level/Actors/StaticModel.cpp @@ -389,7 +389,7 @@ void StaticModel::Draw(RenderContextBatch& renderContextBatch) ACTOR_GET_WORLD_MATRIX(this, view, world); Mesh::DrawInfo draw; draw.DrawModes = _drawModes; - if (drawState && renderContextBatch.Buffers->OcclusionCulling && !renderContextBatch.Buffers->OcclusionCulling->IsVisible(_box, *drawState)) + if (drawState && EnumHasAllFlags(renderContext.View.Flags, ViewFlags::OcclusionCulling) && renderContextBatch.Buffers->OcclusionCulling && !renderContextBatch.Buffers->OcclusionCulling->IsVisible(_box, *drawState)) { // Draw shadows-only (or cull) draw.DrawModes &= DrawPass::Depth; diff --git a/Source/Engine/Particles/ParticleEffect.cpp b/Source/Engine/Particles/ParticleEffect.cpp index c6e9c9483..ed55985a6 100644 --- a/Source/Engine/Particles/ParticleEffect.cpp +++ b/Source/Engine/Particles/ParticleEffect.cpp @@ -617,7 +617,7 @@ void ParticleEffect::Draw(RenderContextBatch& renderContextBatch) return; auto drawState = renderContext.Buffers->GetGeometryDrawState(&GetScene()->Rendering, _sceneRenderingKey, this); DrawPass drawModes = DrawModes; - if (drawState && renderContextBatch.Buffers->OcclusionCulling && !renderContextBatch.Buffers->OcclusionCulling->IsVisible(_box, *drawState)) + if (drawState && EnumHasAllFlags(renderContext.View.Flags, ViewFlags::OcclusionCulling) && renderContextBatch.Buffers->OcclusionCulling && !renderContextBatch.Buffers->OcclusionCulling->IsVisible(_box, *drawState)) drawModes &= DrawPass::Depth; Particles::DrawParticles(renderContextBatch, this, drawModes); diff --git a/Source/Engine/Renderer/Renderer.cpp b/Source/Engine/Renderer/Renderer.cpp index 783145bfa..d03213d74 100644 --- a/Source/Engine/Renderer/Renderer.cpp +++ b/Source/Engine/Renderer/Renderer.cpp @@ -303,6 +303,7 @@ void Renderer::DrawSceneDepth(GPUContext* context, SceneRenderTask* task, GPUTex RenderContext renderContext(task); renderContext.List = RenderList::GetFromPool(); renderContext.View.Pass = DrawPass::Depth; + renderContext.View.Flags &= ~ViewFlags::OcclusionCulling; renderContext.View.Prepare(renderContext); // Call drawing (will collect draw calls) diff --git a/Source/Engine/UI/TextRender.cpp b/Source/Engine/UI/TextRender.cpp index 6f906210e..123f382b3 100644 --- a/Source/Engine/UI/TextRender.cpp +++ b/Source/Engine/UI/TextRender.cpp @@ -378,7 +378,7 @@ void TextRender::Draw(RenderContextBatch& renderContextBatch) renderContext.View.GetWorldMatrix(_transform, world); auto drawState = renderContext.Buffers->GetGeometryDrawState(&GetScene()->Rendering, _sceneRenderingKey, this); DrawPass drawModes = DrawModes; - if (drawState && renderContextBatch.Buffers->OcclusionCulling && !renderContextBatch.Buffers->OcclusionCulling->IsVisible(_box, *drawState)) + if (drawState && EnumHasAllFlags(renderContext.View.Flags, ViewFlags::OcclusionCulling) && renderContextBatch.Buffers->OcclusionCulling && !renderContextBatch.Buffers->OcclusionCulling->IsVisible(_box, *drawState)) { // Draw shadows-only (or cull) drawModes &= DrawPass::Depth;