Get the scene depth into the post pass #88

Closed
opened 2026-10-20 08:49:31 +00:00 by sermuns · 1 comment
Owner

The present pass reads color only. ARCHITECTURE.md records why: GLSL cannot
textureLoad a depth texture, so fog happens in the forward pass and the blit only
tonemaps.

That single constraint blocks every depth-aware effect worth having: post fog,
SSAO, contact shadows, depth of field, and any FXAA that wants edge confidence.

The cheap experiment is textureSample instead of textureLoad on a depth
sampler. The restriction that was hit is specifically on loads; WebGL2 may sample
a depth texture normally. The naga GLSL translation test in
liuverse-render/src/shaders.rs can answer that in an afternoon, which is much
cheaper than designing around it.

If that fails, write linear view depth from the forward pass into a second target:
R32Float where float attachments exist, packed RGBA8 where they do not, or a
plain depth-as-color texture. The forward pass already knows the eye position, so
the value is one length per fragment.

Related: #81 and #82 are the effects this unlocks; the fog decision
in ARCHITECTURE.md is the reason to do it at all.

The present pass reads color only. ARCHITECTURE.md records why: GLSL cannot `textureLoad` a depth texture, so fog happens in the forward pass and the blit only tonemaps. That single constraint blocks every depth-aware effect worth having: post fog, SSAO, contact shadows, depth of field, and any FXAA that wants edge confidence. The cheap experiment is `textureSample` instead of `textureLoad` on a depth sampler. The restriction that was hit is specifically on loads; WebGL2 may sample a depth texture normally. The naga GLSL translation test in `liuverse-render/src/shaders.rs` can answer that in an afternoon, which is much cheaper than designing around it. If that fails, write linear view depth from the forward pass into a second target: `R32Float` where float attachments exist, packed `RGBA8` where they do not, or a plain depth-as-color texture. The forward pass already knows the eye position, so the value is one length per fragment. Related: #81 and #82 are the effects this unlocks; the fog decision in ARCHITECTURE.md is the reason to do it at all.
sermuns added this to the Rendering milestone 2026-10-20 08:49:31 +00:00
Author
Owner

Closing as out of scope. Once SSAO and the near shadow map are dropped it has no consumer left; the forward-pass fog already covers what the scene needs, and nothing else wanted a depth texture.

Closing as out of scope. Once SSAO and the near shadow map are dropped it has no consumer left; the forward-pass fog already covers what the scene needs, and nothing else wanted a depth texture.
Sign in to join this conversation.
No description provided.