Skip to content

Depth pre pass+tl min max#962

Open
RuffledPlume wants to merge 22 commits into117HD:masterfrom
RuffledPlume:DepthPrePass+TLMinMax
Open

Depth pre pass+tl min max#962
RuffledPlume wants to merge 22 commits into117HD:masterfrom
RuffledPlume:DepthPrePass+TLMinMax

Conversation

@RuffledPlume
Copy link
Contributor

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

Occlusion Culling

  • Occlusion Queries containing AABBs which are instanced drawn
    • Dynamic & Temp Draws use Dynamic Occlusion queries based on their hash
    • Zone have a occlusion query containing a AABB representation of the zone tiles & static models
    • Each AlphaModel within a zone has an occlusion query
TileMinMax.mp4

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

RuffledPlume and others added 22 commits February 26, 2026 20:40
### 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
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.

2 participants