fix(VR): underwater mask while partially submerged#2062
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds VR-aware per-eye underwater mask upscaling: reconstructs per-eye positions from SceneDepth, queries per-eye water height, computes underwater status per-pixel, updates SharedData::GetWaterData to accept an eye index, and adjusts upscaling depth SRV binding/copy timing and shader build defines. (≤50 words) Changes
Sequence DiagramsequenceDiagram
participant VS as VS / Input UV
participant PS as UnderwaterMaskUpscalePS
participant SceneDepth as SceneDepth SRV (t1)
participant Camera as FrameBuffer (CameraViewProjInverse, CameraPosAdjust)
participant Shared as SharedData::GetWaterData
participant RT as UnderwaterMask RT
VS->>PS: provide TexCoord (contains stereo UV)
PS->>PS: extract eyeIndex from TexCoord.x and unpack per-eye UV
PS->>SceneDepth: Load depth at per-eye UV
SceneDepth-->>PS: depth
PS->>Camera: read CameraViewProjInverse[eyeIndex] & CameraPosAdjust[eyeIndex]
Camera-->>PS: matrices & per-eye adjust
PS->>PS: reconstruct world position or ray direction
PS->>Shared: GetWaterData(worldPos, eyeIndex)
Shared-->>PS: waterData (adjusted per-eye)
PS->>PS: evaluate underwater test (depth & ray logic)
PS-->>RT: write per-eye UnderwaterMask
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
No actionable suggestions for changed features. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@features/Upscaling/Shaders/Upscaling/UnderwaterMaskUpscalePS.hlsl`:
- Around line 59-103: The VR branch is using raw input.TexCoord for depth
sampling and unprojection, causing TAA jitter to shift the waterline; reapply
the same de-jitter (jitter-compensated) UV used elsewhere before calling
SharedData::ConvertUVToSampleCoord and before building ndc/worldPos.
Specifically, compute the de-jittered eyeUV (using the same jitter removal logic
applied in the non-VR path) and use that de-jittered eyeUV for
SceneDepth.Load(SharedData::ConvertUVToSampleCoord(...)) and when computing ndc
and the mul with FrameBuffer::CameraViewProjInverse[eyeIndex] so
psout.UnderwaterMask is computed from the de-jittered position.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8dcbc4d9-5b31-42d5-93cf-c8e16d6e9215
📒 Files selected for processing (4)
features/Upscaling/Shaders/Upscaling/UnderwaterMaskUpscalePS.hlslpackage/Shaders/Common/SharedData.hlslipackage/Shaders/Lighting.hlslsrc/Features/Upscaling.cpp
|
✅ A pre-release build is available for this PR: |
eb2f03e to
a21fa4c
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
features/Upscaling/Shaders/Upscaling/UnderwaterMaskUpscalePS.hlsl (1)
68-76:⚠️ Potential issue | 🟠 MajorUnproject from the same de-jittered UV you use for depth.
SceneDepthis fetched from de-jittereduv, buteyeUV/ndcstill come from rawinput.TexCoord. That leaves depth sampling and world-position reconstruction out of phase, so the waterline will still shimmer with TAA jitter.🎯 Minimal fix
- // Unpack from side-by-side stereo layout to per-eye UV [0, 1] - float2 eyeUV = float2(input.TexCoord.x * 2.0 - (float)eyeIndex, input.TexCoord.y); + // Unpack the same de-jittered stereo UV into per-eye UV [0, 1] + float2 eyeUV = float2(uv.x * 2.0 - (float)eyeIndex, uv.y);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@features/Upscaling/Shaders/Upscaling/UnderwaterMaskUpscalePS.hlsl` around lines 68 - 76, eyeUV and ndc are computed from raw input.TexCoord while SceneDepth is sampled from the de-jittered uv, causing Z and reconstructed world position to be out-of-sync; update the eyeUV/ndc computation to derive from the same de-jittered stereo UV (uv) used for depth sampling (respect stereo side-by-side layout and SharedData::BufferDim) so that eyeUV, ndc, and the SceneDepth.Load(int3(uv * SharedData::BufferDim.xy, 0)).x all use the same de-jittered coordinates (adjust the math that creates eyeUV and ndc to use uv instead of input.TexCoord).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@features/Upscaling/Shaders/Upscaling/UnderwaterMaskUpscalePS.hlsl`:
- Around line 68-76: eyeUV and ndc are computed from raw input.TexCoord while
SceneDepth is sampled from the de-jittered uv, causing Z and reconstructed world
position to be out-of-sync; update the eyeUV/ndc computation to derive from the
same de-jittered stereo UV (uv) used for depth sampling (respect stereo
side-by-side layout and SharedData::BufferDim) so that eyeUV, ndc, and the
SceneDepth.Load(int3(uv * SharedData::BufferDim.xy, 0)).x all use the same
de-jittered coordinates (adjust the math that creates eyeUV and ndc to use uv
instead of input.TexCoord).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ff3e6257-4dfc-46dc-a260-7bfa328d830a
📒 Files selected for processing (6)
features/Upscaling/Shaders/Features/Upscaling.inifeatures/Upscaling/Shaders/Upscaling/UnderwaterMaskUpscalePS.hlslpackage/Shaders/Common/Math.hlslipackage/Shaders/Common/SharedData.hlslipackage/Shaders/Lighting.hlslsrc/Features/Upscaling.cpp
✅ Files skipped from review due to trivial changes (2)
- package/Shaders/Common/Math.hlsli
- features/Upscaling/Shaders/Features/Upscaling.ini
🚧 Files skipped from review as they are similar to previous changes (1)
- package/Shaders/Common/SharedData.hlsli
Adds a VR diagnostics switch to bypass the community-shaders#2062/community-shaders#2075 underwater mask changes for in-game A/B testing. The toggle disables the analytical underwater mask shader path, the TESWaterSystem fallback height, and the shared VR water-height eye correction while preserving SRV unbind safety.
closes #620
Does not fix it where there's no water data (so whiterun/caves will have vanilla broken behavior).
Summary by CodeRabbit
New Features
Bug Fixes
Chores