Meter the lowest histogram bin in auto exposure - #25798
Merged
alice-i-cecile merged 3 commits intoSep 20, 2026
Merged
Conversation
alice-i-cecile
requested changes
Sep 15, 2026
alice-i-cecile
left a comment
Member
There was a problem hiding this comment.
Can you leave a quick migration guide note? This is the sort of thing that people are going to be baffled by and struggle to track down, even though I think that this is a reasonable refinement.
Otherwise I like this PR and think it's correct: I have some exposure to this stuff via photography and think that this is a better approach than our previous one.
alice-i-cecile
approved these changes
Sep 15, 2026
Zeophlite
approved these changes
Sep 19, 2026
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.
Objective
Auto exposure can make a sudden adjustment when most of the view becomes dark.
To work out how much to brighten or darken the image, auto exposure groups pixels by luminance in a histogram, filters out a percentage of the darkest and brightest samples, and averages the rest.
The problem is that pixels below
AutoExposure::rangecount toward the filtering percentages but get skipped when calculating the average. As the view gets darker, the average still depends on the brighter samples. Once those are all filtered out, it falls back to the minimum luminance, making the target exposure jump.Solution
Include the darkest pixels in the average too. They go into histogram bin 0 and are treated as having the minimum luminance. That lets the average decrease as more of the view gets dark, without the jump when only dark samples remain.
The
filterandmetering_masksettings can still be used to leave dark pixels out.Testing
In addition to testing as part of my Zorah work, I built tests that add more dark pixels in steps and check the exposure against expected values. They reproduce the jump before the fix and show gradual changes afterward. Also checked different luminance ranges, filter settings, and metering masks.
This was AI assisted w/ Fable 5.1 & Astra as part of my work to get the Zorah scene working, which has a lot of very bright and very dark areas, and I was noticing weird behavior after I added auto exposure in, so had the LLM help track it down, put together a fix, and then visually confirm it was fixed. Then built explicit tests to validate exact measurable behavior. Reviewed everything carefully & cleaned it up a bit before posting.