WIP: [pr-feature][rendering][lighting] EXPOSURE: a brightness offset in EV for the finished picture (DARNER_EXPOSURE, off by default, live from F1) #305
Loading…
Reference in a new issue
No description provided.
Delete branch "Jesper-A/Darner:up-exposure"
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?
Contributor role (optional)
What it changes
Some scenes look too dark or too bright on a given screen. README offers GRAY SHADOW LIFT for "too dark" (and LIGHT ESTIMATE for shade and indoors). This adds one more lever: a plain brightness step for the whole picture, up or down, before the HUD is drawn. It is off by default, so nothing changes unless you turn it on.
This is a work in progress. The shader has not run on a GPU yet, and nothing has been measured or looked at in the game. The unit tests and the gates below are all there is so far. Next: a diag build and a short look in SDR and in HDR, then the results go here and
WIP:comes off.DARNER_EXPOSURE: -2 to +2 stops (EV). The picture's light is scaled by 2 to the power of that number: +1 is twice the light, -1 is half. Unset, 0 and any text that is not a number mean off.DARNER_EXPOSURE. (The switch accepts any value from -2 to +2; the menu offers five.)crates/darner-gpu/src/compose.rs), one new root constant (20 becomes 21) that carries the scale.host/hdr.rshas the matching round-trip test).docs/findings.mdentry, and the F1 texts inlocales/en.jsonandlocales/zh-CN.json.What it does not do. It is an output-side offset only. It works on the picture the game has already exposed. It does not change the game's own auto exposure or how fast the game adapts to light (a dark room stays as slow to brighten as before). Changing that would need a hook into the game's code, which this does not attempt. Highlights the game has already clipped stay clipped, and on an 8-bit scene plane a large positive step also lifts banding. The help text in F1 and the README say that the game's own exposure stays.
Related, not fixed by this: #254 reports a phone screen that is very dark indoors and normal outside (an AMD card). EXPOSURE might make such a screen brighter, but that has not been tried, and the cause there may be elsewhere, so this PR does not claim to fix it. #100 (closed, the release discussion) has a report of a scene washed out by white haze. That looks like a different fault (the haze is not a taste setting), and this PR is not meant for it.
How it was tested
9cc0f3d5d(one commit on mainf3840d73d).cargo clippy --workspace --all-targets --locked -- -D warnings: clean.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean.cargo test --workspace --exclude darner-shader --locked --no-fail-fast: everything passes except one test,darner-gpuwatch::tests::ask_once_by_res_splits_reservations_without_refusals. It is in a file this change does not touch. It passed when run alone, twice, and it also failed once in another of our branches' runs today, so it looks flaky. I have not looked for its cause.darner-shaderwas left out because it has 4 known DXIL-validation failures on this PC that this change does not touch. So the third gate as upstream states it (cargo test --workspace --locked) was not run as written.cargo xtask policy: ok.compose::exposure_tests(3 tests: the switch text is parsed and clamped; +1 EV is a factor of 2 in linear light; the shader source text has the new constant, the scaling before the HUD and the skip at scale 1) andhost::hdr::tests::pq_exposure_round_trip(the PQ step in f64: no offset gives the signal back, and an offset scales the nits by 2^EV). One of the threeexposure_testschecks the shader's source text, not what a GPU draws. None of them runs the shader.DARNER_EXPOSUREis set to a non-zero number.cargo test --workspace --lockedgate; the F1 row (layout, saving, the OFF label) has only been checked by reading.Spec dependence. Likely general: the change is in the output composer and has nothing GPU-specific in it. May depend on our specs: how it looks (banding at +1, clipping) depends on the scene plane's format and the title's own tone mapping, and we only have a Series S profile with DLSS Performance on an RTX 2070 SUPER (Turing, 8 GB, ReBAR off, Ryzen 7 5800X, 32 GB, Windows 11 Pro Insider 26320). Untested elsewhere: AMD and Intel cards, Series X, other DLSS modes, other monitors.
Checklist
WIP:.main. (One commit onf3840d73d.)docs/asset-policy.md. (Text only;cargo xtask policyok.)Checked for overlap
compose.rs,host/menu.rsandlocales/en.json(#75 also README.md); #302, #297, #289, #255, #217, #205, #196, #175, #154, #146, #145, #80, #48, #47, #16, #12 and #9 touchhost/menu.rs, and a few alsolocales/en.json. Expect small merge conflicts in the F1 menu table and the locale file. This is a draft, so the branch stays on its base for now.This change was made with AI assistance (Claude Code).
One scope detail before the SDR/HDR run. The exposure math is in
psandps_pq. InHost::present_planes, a full-size plane without an overlay goes throughCopyResourcewhen the formats match. Packed formats useps_single, which also skips exposure. The F1 row will be visible on those paths, but changing it has no effect there.Could the README and F1 help say that exposure applies when the plane compositor is active? A positive test can check for
display output: compositing the planeswhile changing EV. This would keep the before-HUD promise scoped to frames where we can still separate the scene from the interface.Thanks, that is a real gap, and the code path you traced is right.
We took the other route and extended the code instead of narrowing the docs. New commit
170688480on the PR head (up-exposure):ps_singlenow applies the exposure offset.present_placedno longer takes theCopyResourceshortcut. A whole plane without an overlay goes through the plane composer. A linear FP16 plane goes through the single-plane composer.ps_single, the non-PQ branch is a plain multiply with no clamp. The planes that reach it are linear floats, so a 2.2 decode/encode round trip and a clamp would clip HDR values. A PQ output still decodes, scales and encodes.docs/findings.mdnow say the offset applies on every present path.Checked so far, on
170688480:cargo clippy --workspace --all-targets --locked -- -D warningsand the same with--all-featuresare clean.cargo test -p darner-gpu --lockedgave 1761 passed and 1 failed, a known flaky watch test that passed on rerun.cargo xtask policyis ok. I did not run the fullcargo test --workspace --locked.Not tested: nothing has run on a GPU yet. The SDR, HDR10, FP16 and packed-float look, and the cost of the extra draw, come with the in-game run.
On the positive check:
display output: compositing the planesis logged once per run and already fires for any overlay or placed plane, so it will likely be in the log from normal HUD play before EV changes, and a whole FP16 plane (single-plane composer) never logs it. So it is not proof that exposure is applied. We will judge the change from the picture, on a scene without the HUD as well as with it.This comment was written with AI assistance (Claude Code).
Thanks for covering the whole-plane paths. There is one more fallback issue on
170688480. If the regular composer is still pending or cannot be created,show_base_onlycalls back throughpresent_planes. With exposure active, a whole SDR plane then selects the same composer again.4bc7d8c makes that retry a base-only present, so a copyable plane can be shown while the composer is unavailable. In the synthetic routing check, both an SDR plane with an overlay and a whole SDR plane went from repeated composer attempts to one attempt followed by a copy. The no-exposure, explicit output-format and linear FP16 cases retained their behavior. The focused GPU crate type check and asset policy passed. GPU output remains to be checked on the same bench as the exposure change.
If you cherry-pick or rebase the contribution, please keep the Git author. If you fold it into your own commit, please add this trailer.
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>Code review only (read the diff at
1706884), nothing built or run. The forge's "not mergeable" is the WIP/draft state: the branch sits on the currentmaintip, so it has no conflict withmainitself.show_base_onlyre-enterspresent_planeswith no overlay, and a whole plane now selects the composer again. IfComposer::newkeeps failing, orcomposer_asideis still pending withDARNER_COMPOSER_ASIDE=1, it callsshow_base_onlyagain with nothing to stop it. That is unbounded recursion, so likely a stack overflow, wheremainends in aCopyResource.4bc7d8cabove (a base-only retry) fixes it. Passing "exposure off" into the fallback would too.sceneas HUD-less colour, while the back buffer is scaled by 2^EV. Where frame generation finds the HUD by difference (always in HDR10; in SDR with #344 when a Darner overlay is drawn), every pixel then differs. Worth including FG on, EXPOSURE ±1 in the planned in-game run. GRAY SHADOW LIFT already has the same mismatch onmain, to a lesser degree.exposure_ev()reads the environment twice per present. An atomic set by the live F1 row would avoid that.main.CONSTANTS. #344 changesHost::presentnext to this and interacts as above. The fog and sparkle reports (#20, #206) are not addressed by an output offset, as the description already says.Reviewed with Claude Code (AI-assisted); findings checked by a human before posting.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.