fix(shader): select scene depth decode via CAPS_TEXTURE_FLOAT_RENDERABLE#8856
Merged
Conversation
Materials sampling scene depth via screenDepthPS decoded it in the wrong format on textureFloatRenderable devices. The prepass allocates the linear depth texture as R32F when device.textureFloatRenderable (packed RGBA8 otherwise), but the chunk's decode was gated by a separate SCENE_DEPTHMAP_FLOAT define that the material path never set. Select the decode in the chunk from the global CAPS_TEXTURE_FLOAT_RENDERABLE define instead, so the texture format and the shader decode share a single source of truth. Removes SCENE_DEPTHMAP_FLOAT and the device branch (and unused device param) from addScreenDepthChunkDefines, and updates its four callers.
3 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes incorrect scene-depth decoding in GLSL screenDepthPS on textureFloatRenderable devices by making the decode path follow the same single source of truth used to choose the prepass depth texture format (CAPS_TEXTURE_FLOAT_RENDERABLE). This prevents float-vs-packed format disagreement that caused zebra/banding artifacts in materials and effects sampling uSceneDepthMap.
Changes:
- Updated the GLSL
screenDepthchunk to select R32F vs packed RGBA8 decode viaCAPS_TEXTURE_FLOAT_RENDERABLEinstead ofSCENE_DEPTHMAP_FLOAT. - Removed
SCENE_DEPTHMAP_FLOATemission and simplifiedShaderUtils.addScreenDepthChunkDefines(droppeddeviceparameter; now only addsSCENE_DEPTHMAP_LINEARbased on camera params). - Updated affected post-process passes (TAA, SSAO, CoC, depth-aware blur) to the new
addScreenDepthChunkDefinessignature.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/scene/shader-lib/shader-utils.js | Removes SCENE_DEPTHMAP_FLOAT define emission and updates helper signature to rely on global caps define. |
| src/scene/shader-lib/glsl/chunks/common/frag/screenDepth.js | Switches float-vs-packed depth decode selection to CAPS_TEXTURE_FLOAT_RENDERABLE. |
| src/extras/render-passes/render-pass-taa.js | Updates helper invocation to new signature. |
| src/extras/render-passes/render-pass-ssao.js | Updates helper invocation to new signature. |
| src/extras/render-passes/render-pass-depth-aware-blur.js | Updates helper invocation to new signature. |
| src/extras/render-passes/render-pass-coc.js | Updates helper invocation to new signature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mvaligursky
added a commit
that referenced
this pull request
Jun 8, 2026
…BLE (#8856) Materials sampling scene depth via screenDepthPS decoded it in the wrong format on textureFloatRenderable devices. The prepass allocates the linear depth texture as R32F when device.textureFloatRenderable (packed RGBA8 otherwise), but the chunk's decode was gated by a separate SCENE_DEPTHMAP_FLOAT define that the material path never set. Select the decode in the chunk from the global CAPS_TEXTURE_FLOAT_RENDERABLE define instead, so the texture format and the shader decode share a single source of truth. Removes SCENE_DEPTHMAP_FLOAT and the device branch (and unused device param) from addScreenDepthChunkDefines, and updates its four callers. Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Materials sampling scene depth via the
screenDepthPSchunk decoded it in the wrong format ontextureFloatRenderabledevices, producing zebra/banding artifacts (e.g. the ground-fog effect and StandardMaterial paths readinguSceneDepthMap).This is an alternative to #8851. Rather than injecting a
SCENE_DEPTHMAP_FLOATdefine onto the material path, it removes that define entirely and selects the decode in the chunk from the globalCAPS_TEXTURE_FLOAT_RENDERABLEdefine instead.Root cause:
RenderPassPrepassallocates the linear depth texture asR32Fwhendevice.textureFloatRenderable(packedRGBA8otherwise), but thescreenDepthPSdecode was gated by a separateSCENE_DEPTHMAP_FLOATdefine that the material path (ShaderUtils.getCoreDefines) never set — so the shader took the packed-RGBA8 branch against an R32F texture. The two were independent flags that could disagree.Changes:
screenDepthGLSL chunk now selects the float vs packed-RGBA8 decode usingCAPS_TEXTURE_FLOAT_RENDERABLE, whichinitCapsDefinesalready emits into every shader from the samedevice.textureFloatRenderableflag the prepass uses. Format and decode now share a single source of truth and can never disagree.SCENE_DEPTHMAP_FLOATdefine and dropped thedevice.textureFloatRenderablebranch (plus the now-unuseddeviceparam) fromShaderUtils.addScreenDepthChunkDefines, which now only sets the camera-specificSCENE_DEPTHMAP_LINEAR.addScreenDepthChunkDefinessignature.The WGSL chunk was unaffected — it never had a float branch.