Skip to content

TEST-910: sun shadow map for the G-buffer sandbox with the game's depth-only VS - #4436

Open
Joaovitor404silva wants to merge 3 commits into
ItsNotRexed:mainfrom
Joaovitor404silva:deferred-light
Open

Joaovitor404silva wants to merge 3 commits into
ItsNotRexed:mainfrom
Joaovitor404silva:deferred-light

Conversation

@Joaovitor404silva

@Joaovitor404silva Joaovitor404silva commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: TEST-910

Depends on: #4119
Depends on: #3530

What and why

Sun shadows for the G-buffer sandbox of TEST-728 (#4119). This is the first step towards deferred sun light over the G-buffer.

  • vk_gbuffer --shadow <vs.spv> [--sun az el] draws every prop into a 2048² D32 map from an orthographic sun with a translated depth-only VS from the user's work folder. Each covered G-buffer pixel is moved back to world space through the inverse view-projection and tested against the map with a normal offset and a world-unit depth bias. It prints counts only: lit, shadowed, facing away, outside.
  • tools/gbuffer.py --shadow picks that VS by layout, not by name: SV_VertexID as the only input, no bindings, user SGPRs [ptr32_lo 9, const32 11, const32 12], object rows at s9 + 0x40, view-projection at s9 + 0x60 → 0x160, a float3 stream at s11/s12, exports pos0 + param0. It runs two opposite suns.
  • PASS for each sun: a non-empty map, lit > 0 and shadowed ≥ 1 % of the tested pixels. The two lit counts must also differ by ≥ 10 % of the tested pixels, since opposite suns light opposite faces.
  • docs/gbuffer_sandbox.md §5 documents the tables, the test and the numbers.

Not in this PR: the shadow test and N·L run on the CPU. Running the game's shadow-mask and deferred lighting shaders over these targets is the next step.

Tested

RTX 4070 Ti SUPER, NVIDIA 621.24, Windows 11. Test scene from sandbox.md (150 props, 446 draws), 640×360:

sun (azimuth/elevation) lit shadowed facing away
135°/50° 82,784 10,529 21,190
315°/50° 13,420 17,164 83,919
  • The TEST-728 counts are unchanged: 114,503 covered and shaded. Without --shadow the run is the same as before.
  • 2 VS in the translated corpus match the layout.
  • python -I tests/test_gbuffer_shadow.py: 22 tests OK, on hand-written listings. tests/test_gbuffer_pick.py OK. The build has no warnings.

AI-assisted (Claude Code). Reviewed with an automated code review; its findings are fixed.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

https://claude.ai/code/session_01PiKMETzszqwfnV8QQyzocY

Joaovitor404silva and others added 3 commits November 22, 2026 20:27
vk_sandbox draws the props around a point with one translated game VS/PS
pair chosen by signature and descriptor layout: a real camera through the
VS constants, DiffuseTex albedo through the bindless set and the PS's own
S#, depth, and a fly/walk/drive window. tools/sandbox.py packs the scene
(tools/sandbox_scene.py), picks the pair and runs it; --check prints
counts only. docs/sandbox.md has the table layout and the measurements.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PiKMETzszqwfnV8QQyzocY
…G-buffer

tools/gbuffer.py picks a material VS/PS pair by user data and listing
layout. The VS pulls its own vertices and the PS writes the five G-buffer
targets. The script links the pair's interpolants by DXBC semantic and
runs runtime/test/vk_gbuffer. That tool repacks the scene into the
game's compressed vertex stream, fills the tables the pair reads, draws
into mrt0-4 + D32 and reads every target back. It prints counts and
PASS/FAIL only.

The scene and camera helpers move from vk_sandbox.cpp to
sandbox_common.h. docs/gbuffer.md records the tables, the stream and the
target layout. tests/test_gbuffer_pick.py covers picking, linking and
the thresholds on hand-made inputs.

Depends on: ItsNotRexed#3530

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PiKMETzszqwfnV8QQyzocY
vk_gbuffer --shadow draws every prop into a 2048^2 D32 map from an
orthographic sun with a depth-only VS picked by layout (SV_VertexID in,
s9 object/view tables, float3 stream at s11/s12), then tests each covered
G-buffer pixel against it and counts lit, shadowed and facing away.
gbuffer.py --shadow runs two opposite suns and needs lit and shadowed
pixels under each, with different counts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PiKMETzszqwfnV8QQyzocY

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this at e5301e92 on Windows 11: pytest tests/test_gbuffer_shadow.py tests/test_gbuffer_pick.py tests/test_sandbox_pick.py tests/test_sandbox_scene.py -q -> 45 passed; git diff --check clean.

The new shadow test covers the depth-only VS selection, the sun direction and the shadow map packing; the existing G-buffer/sandbox tests pass. I did not run the GPU vk_gbuffer --shadow path here because it needs the user's scene/shader carve (this branch stacks #4119/#3530). No blocking issue on the CPU side.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested e5301e9 merged onto main d0835dd on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:

  • Full ctest: 155/155.
  • Warnings: none new in the files this PR changes.

AI-assisted (Claude Code).

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.

3 participants