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.
Background
I noticed that applying the CRT filter with parameters that should be neutral would instead affect the brightness of sources, and ended up digging into the sRGB handling.
I created a test image, which may not preview correctly here:
The top half has checkerboards of black and white pixels at different scales, against a mid-grey background. The bottom half is similar but with transparent and white checkerboards and a mid-transparent white background.
If viewing the image at 1:1 pixel scale, composited on a black background, with decent monitor calibration and nothing like f.lux running that messes with color curves, when looking at the image from a distance the checkerboards should fade into the background color. The 1px checkerboards might not, depending on monitor subpixels.
The image is a good check that the srgb conversions in a filter are correct, that alpha is handled correctly, etc.
Testing
I'm testing on a 1080p canvas with a scene that has a black color source under the test image, set to apply alpha in linear space.
I'm testing with most of the CRT filter settings turned off, and just playing with bloom settings.
Results
Please view results at 1:1 scale and without f.lux / night mode!
Before this PR, with no bloom:
After this PR, with no bloom:
This image looks correct and top and bottom sections look identical.
Before this PR, 16px strong bloom:
After this PR, 16 px strong bloom:
It's not yet perfect in terms of the alpha results, but it's an improvement.
Before this PR, 16px medium bloom:
After this PR, 16 px medium bloom:
The bloom and compositing have changed, but with some tweaks to the parameters a similar look can be recreated:
Before, defaults with with black/white levels at 0/255:
After, and tweaking params:
Implementation
gs_effect_set_texture_srgb
is called instead ofgs_effect_set_texture
for texture parameters that should be srgb-decoded.gs_enable_framebuffer_srgb(true)
is called when rendering to a render target that should be srgb-encoded.Blur is performed on premultiplied colors.
Bloom is changed to a linear mix of premultiplied samples. This is more physically correct; the existing bloom is more like the classic XB360 era bloom, that might be fun as its own retro effect!