Skip to content

Depth PrePass, TiledLighting Min/Max & Occlusion Culling#942

Closed
RuffledPlume wants to merge 18 commits into117HD:masterfrom
RuffledPlume:DepthPrePass+TLMinMax
Closed

Depth PrePass, TiledLighting Min/Max & Occlusion Culling#942
RuffledPlume wants to merge 18 commits into117HD:masterfrom
RuffledPlume:DepthPrePass+TLMinMax

Conversation

@RuffledPlume
Copy link
Copy Markdown
Contributor

@RuffledPlume RuffledPlume commented Feb 17, 2026

Based of #921

SceneFBO Changes

  • SceneOpaqueDepth buffer switched from RenderBuffer to Texture2DMSAA
  • Format changed from 32F to 24
  • SceneAlphaDepth added, format set to 16 since precision isn't needed for depth testing

Depth Shader Program

  • DepthBias encoded into last 8 bits of the textureFaceIdx, to avoid needing to sample the texture buffer to resolve it
  • FastDepth is utilized without a fragment shader attached

Zone Renderer

  • Clearing of the fboScene has been moved to its own pass
  • depthprePass added
    • Renders Opaque Depth to the sceneFBO
    • Renders Alpha Depth into a separate fbo for sampling only
  • zone & VAO are added into a new command buffer for drawing into opaque & alpha depth buffers separately
TileMinMax.mp4

Laptop GPU Bound Example (Base 921 PR Left, 942 PR Right)
image Screenshot From 2026-02-17 16-13-18

@RuffledPlume RuffledPlume force-pushed the DepthPrePass+TLMinMax branch 8 times, most recently from 7bca84d to a60ee67 Compare February 21, 2026 22:20
@RuffledPlume RuffledPlume changed the title Depth PrePass & TiledLighting Min/Max Depth PrePass, TiledLighting Min/Max & Occlusion Culling Feb 21, 2026
@RuffledPlume RuffledPlume force-pushed the DepthPrePass+TLMinMax branch 2 times, most recently from b7e6549 to e984af2 Compare February 23, 2026 03:38
@RuffledPlume RuffledPlume marked this pull request as draft February 23, 2026 03:40
@RuffledPlume RuffledPlume force-pushed the DepthPrePass+TLMinMax branch 4 times, most recently from 9a8f790 to 982510d Compare February 25, 2026 18:58
@RuffledPlume RuffledPlume marked this pull request as ready for review February 25, 2026 19:06
@RuffledPlume
Copy link
Copy Markdown
Contributor Author

RuffledPlume commented Feb 25, 2026

Main branch:
image

PR Branch:
image

@RuffledPlume RuffledPlume force-pushed the DepthPrePass+TLMinMax branch 8 times, most recently from 824d24c to d1c2043 Compare February 26, 2026 06:18
### SceneFBO Changes
 * SceneOpaqueDepth buffer switched from RenderBuffer to Texture2DMSAA
 * Format changed from 32F to 24
 * SceneAlphaDepth added, format set to 16 since precision isn't needed for depth testing

### Depth Shader Program
 * DepthBias encoded into last 8 bits of the textureFaceIdx, to avoid needing to sample the texture buffer to resolve it
 * FastDepth is utilized without a fragment shader attached

### Zone Renderer
 *  Clearing of the fboScene has been moved to its own pass
 * depthprePass added
   * Renders Opaque Depth to the sceneFBO
   * Renders Alpha Depth into a separate fbo for sampling only
 * zone & VAO are added into a new command buffer for drawing into opaque & alpha depth buffers separately

optimised calculateTileMinMax

Sampling corners & midpoints is sufficently accurate, which reduces depth taps from 16x16x2 to just 3x3x2

Optimised LightZ Vs MinMax by removing sqrt
Also optimised distanceScore by using squared values instead of linear

Sync

Simplify tile depth check

Moved Tile Depth check to be before all the cone culling checks

we want 3x3x2 not 4x4x2
Disabled culling lights behind the camera, it will now be culled by the min/maxing

Sync
Expanded Occlusion Queries to directional draw

added isVisible

Sync
Sync
Disable Occlusion Culling Direction Queries when Shadow Alpha enabled

Added Debug Visualiser Support

Sync

Sync

Dont spin wait, continue if its not available
Queries need to be double buffered

Sync
Sync

Sync

Sync

Buffer Samples to ensure minimal readback delay

Directional Queries should sample scene depth FBO with the AABB expanded along the directional camera forward to see if the expanded AABB is visible

Fixed Directional Shadow AABB Expanding

Zones will now remove encapsulated AABBs

Sync

Dont getAABB when occlusion culling is disabled

Sync

Added BindBufferRange support to uniform buffer

Sync

Sync

Sync

Fix Flicker

Always set worldView since the player can enter a boat & leave

Switch to back face culling, otherwise we consider AABBs occluded whilst inside the AABB.

Alternatively we could test if the camera is inside & skip those checks

Skip occlusion queries if the camera is within any of its AABBs

Debug Stuff

Moved assert

Fixed Dynamic Occlusion queries not resting their AABBs each frame

AABB Fixes

Fix World View projected AABBs

Frustum Cull AABBs

Sync

Occlusion Query Frustum Culling

Sync

Formatting

Frustum Cull Query AABBs to reduce needless rendering

Fixes

Sync

Sync

Sync

Sync

Added KeyBind to toggle between Static+Dynamic/Static/Dynamic
TODO: move sceneDepthFBo resolve out of occlusion so that tiledlighting min/max & scene shader can use it
Optimizations

Optimizations
@RuffledPlume
Copy link
Copy Markdown
Contributor Author

Dunno why it closed lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant