Optimize SSAO rendering with depth bounds and half-res depth buffer

This commit is contained in:
Wojtek Figat
2026-01-20 00:22:27 +01:00
parent 877d57681d
commit 192d3d1a8e
8 changed files with 60 additions and 26 deletions

View File

@@ -695,6 +695,15 @@ Float2 RenderTools::GetDepthBounds(const RenderView& view, const OrientedBoundin
return GetDepthBounds(view, Span<Float3>(corners, 8));
}
float RenderTools::GetDepthBounds(const RenderView& view, const Float3& point)
{
const Float4 pointClip = Matrix::TransformPosition(view.ViewProjection(), Float4(point, 1.0));
float depth = pointClip.Z / pointClip.W;
if (depth >= 1.0f)
depth = 0.0f; // Point is behind the view
return Math::Clamp(depth, 0.0f, 1.0f);
}
Float3 RenderTools::GetColorQuantizationError(PixelFormat format)
{
Float3 mantissaBits;