fix(vk): the Lens of Truth's eye at the picture's own shape on ultrawide and 16:10 screens #2713
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2713
Loading…
Reference in a new issue
No description provided.
Delete branch "bulldogsajr22/Longshot:fix/lens-eye-ultrawide"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
On a picture wider than 16:9, the Lens of Truth's purple eye is drawn stretched to the screen's width, but what the Lens reveals is not: the reveal stays 1.4 half heights wide, as on 16:9. Between the reveal's edge and the drawn eye's tips, a strip inside each side of the eye shows the scene un-revealed: the "white sliver" a player sees inside the eye's tips, most visible where a wall is behind it (the left wall in the screenshots below).
To see it on
main: Graphics, Aspect ratio 21:9 and Output resolution 5120x2160 (or any 21:9 size), the Shadow Temple B4 (the corridor in the screenshots), put the Lens on. The drawn eye's tips are 1.86 half heights from the centre; the reveal stops at 1.40, leaving 0.46 half heights unrevealed inside each tip. Onmainthe eye is always 79 % of the picture's width (1.4 half heights at 16:9), so at 32:9 its tips reach 2.8 half heights. On a picture narrower than 16:9 the eye is too narrow instead: at 16:10 (the Steam Deck's shape) its tips are 1.25–1.28 half heights from the centre, and the reveal reaches 0.14 half heights past them, under the swirl, where it is hard to see.Why: the eye is drawn by one program,
d547af983903a518, over a ring mesh across the picture. Its fragment program works out each pixel's place in the eye with 16:9 baked in: the eye's edge is0.9 (1 - (1.26984131 x)^2), where 1.26984131 is 16:9 over the eye's half width of 1.4 (GlassTruthControllerParam's RadiusX), and it takes x into half heights for the eye's ring, bands and edge distance as3.55555558 u - 1.77777779(and-1.77777779again on the edge's slope). The reveal is sized in half heights by the game's code at every shape, so on any other shape the two part. Three more 16:9 assumptions show once that is fixed:This adds an IR pass,
lens_eye_pass.h, run on that program as it is translated:LensEyePass(fragment): finds the eye's edge by its shape (FPMulby 1.26984131, squared,FPFma(sq, -0.9, 0.9); exactly one such edge, in a fragment program reading the effect's camera bank 13). It takes the picture's shape from that bank's projection,P[1][1] / P[0][0](+0x94 / +0x80), once at the program's start, and gives the eye's scale that shape over 1.4, and the program's ±16:9 and ±2×16:9 immediates (in its float multiplies, adds and fused multiply-adds) that shape and twice it. The eye's x (x / 1.4 in half heights) is then clamped at 16:9's side, ±1.26984131, for everything that reads it: inside 16:9's side nothing changes; past it, on a wider picture, the swirl keeps the glow of 16:9's side out to the picture's own.LensEyeVertexPass(vertex, only for the program whose fragment programLensEyePasschanged): narrows the ring's hole with the eye, x times(1 - w) 16:9/shape + w, with the same weight the game gives y for the eye's opening (0 on the hole's edge, 1 at the picture's); and gives the swirl noise's u the vertex's place in 16:9's terms,0.5 + x' (shape / 16:9) / 2, x' the ring's x after that.A projection with no sane shape (outside 1:2 to 10:1, NaN, an unbound bank) keeps the game's constants. At 16:9 the pass gives back the game's values (in the test: the eye's constant within 2e-7, the place in half heights to the bit, the ring's x and the noise's u within 1e-5; in the game: the same eye, measured below). The camera bank's bound size is raised to cover +0x94 when the game's program read less.
Read first:
gpu/vk/eden/shader_recompiler/ir_opt/lens_eye_pass.h, then its two calls ingpu/vk/vk_shader.cpp(translate(), and the graphics pair after it), thentests/lens_eye_ir.cppandtests/test_lens_eye_pass.py.No issue or pull request covers it (
forge.py search --state allfor lens, truth, GlassTruth, ultrawide, 21:9 and the program's key). Related, not changed here: #1867, the Lens's purple effect distorting under FSR 3.1 frame generation at 16:9.Testing
Tested: Windows 11 Pro (26H2, build 26300), RTX 5090, NVIDIA 621.40, HDR, DLSS, 5120x2160 21:9 monitor. The Shadow Temple B4 save, the Lens on and off, the camera turned both ways. Each part was played in the build that added it, and the whole of it (this head's game code, before its rebase from
a3591a98ontoa845154d, which changes neither the eye's instructions nor the IR passes) at 21:9, 32:9 and 16:9; the 21:9 and 16:10 screenshots and the cost are of this head's game code ona845154d:main@a845154dat the same spot: 1.86), meeting the reveal: no unrevealed strip (screenshots below). The swirl looks as on 16:9.main: 2.8 by the 79 %; not measured), no strip. The swirl's sparkles 1.15 times as wide as high (16:9: 1.01; before the noise change: 1.75). With the glow clamp, the far sides at a video luma of 74 (main: 71; before the clamp: 101, burnt out). Before the clamp, a shimmer under DLSS on the side the scene moves toward while turning was seen in two of three sessions; with it, in none of two with the same steps.main@a845154dat the same spot: 1.28 / 1.25); the swirl as on 16:9.main.vk: program d547af983903a518: the Lens of Truth's eye at the picture's shape, its ring with it, its swirl too.Checks:
tests/test_lens_eye_pass.pypasses: synthetic eye programs through the pass, the eye 1.4 half heights wide at 16:9, 2.37, 2.4, 32:9, 16:10 and 4:3; the game's constants at 16:9 and with no sane projection; the ring's hole and the noise's u at 16:9, 21:9, 32:9, 16:10 and 4:3; the clamped x at 16:9, 21:9 and 32:9; programs of other shapes left alone; and the wiring invk_shader.cpp. With both passes doing nothing (main's behaviour) it fails:shape 2.37037: half width 1.86667.mise run teston Linux (WSL, Ubuntu 26.04), withmise.toml's pinned tools in a clean environment: 848 pass, 12 fail, 9 skipped. The same 12 fail onmain@a845154dalone, run the same way:test_bug_report,test_control_picture,test_crash_record,test_guest_holes(UploadLayoutGuardundeclared in its fixture),test_input_background,test_linux_saves_move,test_log_open_failure,test_perf_send(its sender fixture doesn't compile),test_pipeline_tour,test_screensaver(show_game_windowand others undeclared in its fixture),test_switch_table(LONGSHOT_LAUNCHER_STARTUP, read inhost/launcher_startup.h, has no row inswitches.def) andtest_xinput_thread. No existing check was changed.mise run lintpasses.from-source, thenbuild) and played as above; the Linux build is left to CI's renderer build check.Still to test:
main: 79 %) and no unrevealed strip inside its tips (@Beanstalk)main: 79 %), its tips where the reveal ends (@Beanstalk)Measurements
Verdict: fixed: at 21:9 the drawn eye is 1.40 half heights wide, the reveal's width (
main: 1.86, 0.46 half heights of each tip unrevealed); 16:10 1.41 (main: 1.26, inside the reveal); 16:9 unchanged. No cost measured: GPU time 10.9 ms a frame with the Lens on (main: 10.9–11.0).Setup: Windows 11 Pro 26300, RTX 5090, NVIDIA 621.40; 5120x2160, HDR, DLSS, G-SYNC with a 158 fps cap (not reached: about 80 fps). The Shadow Temple B4 save at the screenshots' spot, the Lens on, standing still about 90 s a run; runs alternated main, PR, main, PR. Eye widths: from the screenshots, along the picture's middle row, in half heights of the picture. GPU time and fps: the median of each run's
GPU timeandpresentslines (one each 120 presents) once the room was drawn. This PR's column is8aa47b40, this head's game code (the head adds test shapes only).a845154d8aa47b40tests/test_lens_eye_pass.pyScreenshots of the same spot with the Lens on,
main@a845154dand this PR @8aa47b40, at 5120x2160 (onmainthe left wall turns light inside the eye's left tip) and at 3840x2400 (16:10): in a comment below.Risks
Only the Lens of Truth's eye changes: the one fragment program the pass recognises by its exact edge formula, reading the effect's camera bank, and its vertex program. Anything else is left as translated. Every shape other than 16:9 changes, the Steam Deck's 16:10 among them (Tier 1: in Still to test); at 16:9 the eye is the game's. If the game's projection in bank 13 were ever not the picture's (a shape out of 1:2 to 10:1, or not a number), the eye keeps the game's 16:9 constants, as on
main. The added work is a reciprocal and a few multiplies at the start of each of the two programs and one clamp; no cost showed in GPU time at the 0.1 ms the log gives. The change is in the shader translator's sources, so its stamp moves: every player's shader caches are dropped and every program is translated again once after updating, as for any translator change. A revert undoes it; there is no switch.Not changed here: at 32:9 the swirl's sparkles are still slightly wider than high (1.15 against 16:9's 1.01), the cause not traced (the noise's u, the swirl texture's polar place and the sparkle grid are all in half heights now); at 21:9 they look as on 16:9.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.mainand here, for a change that shows on screen.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Windows 11 Pro 26300, RTX 5090, NVIDIA 621.40, HDR, DLSS: the Shadow Temple B4 with the Lens of Truth on and off, the camera turned both ways, at 5120x2160 (21:9), 5120x1440 (32:9), 3840x2160 (16:9) and 3840x2400 (16:10). On 21:9 and 32:9 the drawn eye's tips meet the reveal (1.40 half heights; main 1.86 at 21:9) with no unrevealed strip, the swirl isn't stretched and its far sides don't burn out; at 16:10 the eye is the reveal's width too (main: too narrow); on 16:9 the eye and swirl are as on main.
WIP: fix(vk): the Lens of Truth's eye at the picture's own shape on ultrawide screensto WIP: fix(vk): the Lens of Truth's eye at the picture's own shape on ultrawide and 16:10 screensThe same spot in the Shadow Temple B4, 5120x2160 (21:9), the Lens of Truth on, standing still (scaled to 2575x1086).
main@a845154d: the drawn eye's tips reach 1.86 half heights, the reveal stops at 1.40; the left wall turns light inside the eye's left tip, the unrevealed strip.This PR @
8aa47b40: the eye's tips at 1.40 half heights, where the reveal ends; the wall is drawn the same all the way to the tip.The same spot at 3840x2400 (16:10, pillarboxed on a 21:9 monitor, scaled to 1739x1086 inside the bars), the Lens on.
main@a845154d: the eye's tips at 1.28 / 1.25 half heights, narrower than the reveal's 1.40 (the reveal reaches past them under the swirl).This PR @
8aa47b40: the tips at 1.41 / 1.42 half heights, the reveal's width.@review
Recommendation: Approve. The code is ready: only testing is left. The Windows test shows the eye meeting the reveal, with no measurable GPU-time cost at the reported precision. The renderer change still needs the stated Tier 1 runs and a check of its shader-translation cost. Recommend approval; not approved on the forge.
The change adjusts the Lens eye, ring and swirl to the picture’s aspect ratio. It fixes the reported mismatch on the tested NVIDIA system, at the cost of scanning fragment IR during translation and invalidating shader caches once.
Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/eden/shader_recompiler/ir_opt/lens_eye_pass.h:64: The changed shader has not been exercised on Linux AMD. (more on the line) Do: Run the stated 21:9 Lens on/off and camera-turn check on Linux AMD and record the result.gpu/vk/eden/shader_recompiler/ir_opt/lens_eye_pass.h:150: The narrower-picture path has not been exercised on Steam Deck. (more on the line) Do: Run the stated Lens on/off and opening/closing check on Steam Deck and record the result.gpu/vk/vk_shader.cpp:804: The reported GPU timing does not cover the added work during shader translation. (more on the line) Do: Compare cold-cache translation and first-run loading time against the base on the same system, and report the results. (@fixdoes its part first: Avoid constructing the users map for programs that have no candidate eye-scale instruction.)@fixcan do L3.Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes on the tested Windows RTX 5090: at 21:9 the eye’s half width fell from 1.86 to 1.40 half heights, matching the reveal; at 16:10 it rose from 1.25–1.28 to 1.41–1.42. Two interleaved runs reported 10.9–11.0 ms before and 10.9 ms after; those figures do not establish a performance gain.
Other systems: The pass affects matching fragment programs on Vulkan systems and their paired vertex program on the ordinary graphics path. Windows NVIDIA was tested; Linux AMD and Steam Deck remain untested. Mesh pipelines also translate fragments through the pass, but the supplied evidence does not show the Lens using that path. Shader-cache invalidation and the added translation scan affect first use after updating.
Switches: None.
Reviewed:
f7adce52d4againsta845154d34: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the pull request template, all four changed files, commit messages, the supplied comments and CI status, and relevant translation and buffer-binding code. Skimmed the test runner and shader IR support. docs/review-checklist.md and the adjacent Tooling checkout were absent; linked screenshots were not available in the closed network.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run as requested. The author reports game runs and a game-free test; CI is still running.
Overlaps and merge order: No overlapping pull requests were identified in the supplied material; the network was closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -0,0 +61,4 @@} // namespace lens_eye_detail/// The eye's x scale made the picture's shape over 1.4; nullptr when made, else why this program is not the eye'sinline const char* LensEyePass(IR::Program& program) {L1 (should fix): The changed shader has not been exercised on Linux AMD.
When: A Linux player on a Tier 1 AMD GPU uses the Lens at ultrawide aspect ratio; the Windows NVIDIA result does not show whether that driver renders the changed eye and swirl correctly.
Do: Run the stated 21:9 Lens on/off and camera-turn check on Linux AMD and record the result.
@ -0,0 +147,4 @@return nullptr;}/// For the eye's vertex program (its fragment program's LensEyePass made): the ring's hole narrowed with the eye, x timesL2 (should fix): The narrower-picture path has not been exercised on Steam Deck.
When: A Deck player uses the Lens at its native 16:10 aspect ratio; the synthetic IR test and a pillarboxed Windows run do not cover the Deck’s Vulkan driver.
Do: Run the stated Lens on/off and opening/closing check on Steam Deck and record the result.
@ -799,2 +801,4 @@one_exit};t->program = Shader::Maxwell::TranslateProgram(t->pools->insts, t->pools->blocks, env, cfg, host_info());// (longshot) the Lens of Truth's eye at the picture's shape (lens_eye_pass.h): its fragment program, whichever pipeline draws itif (graphics && t->program.stage == Shader::Stage::Fragment && !Shader::Optimization::LensEyePass(t->program)) t->lens_eye = true;L3 (should fix): The reported GPU timing does not cover the added work during shader translation.
When: After updating, players rebuild their shader cache, and every fragment program with camera bank 13 builds a users map and scans its IR even when it is not the Lens shader; the effect on loading and first-use stutter is unknown.
Do: Compare cold-cache translation and first-run loading time against the base on the same system, and report the results.
WIP: fix(vk): the Lens of Truth's eye at the picture's own shape on ultrawide and 16:10 screensto fix(vk): the Lens of Truth's eye at the picture's own shape on ultrawide and 16:10 screens