softgpu: Correct accuracy of fog calculation #16005
Merged
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.
Having figured out how to directly specify the 8-bit fog factor in #15978, I was able to directly verify the fog blending equation on hardware (without Z interpolation and floating point handling questions getting in the way.)
It's the same as the BLEND tex func, i.e. divide by 256 but round up. No halves, no dividing by 255, simple.
I had to do some ugly hacking to get the fog values from imm to the actual verts (not included here, and only working for some prims.) This matches a test of many values/factors exactly,. bit-for-bit. The test included every possible source color + every possible factor + a couple fog colors chosen to catch rounding problems.
-[Unknown]