Add FXAA support to the Compatibility renderer#113763
Conversation
1aed91c to
6bd74b3
Compare
I believe the order is the best it can be for the same reasons as described in my earlier comment.
At first glance, this looks right to me (I see that you've inverted it to match the style of the Compatibility renderer). I don't know FXAA well enough to know if there are implications to applying the luminance multiplier to Also, I notice that you're passing in |
| } | ||
|
|
||
| float rgb2luma(vec3 rgb) { | ||
| return sqrt(dot(rgb, vec3(0.299, 0.587, 0.114))); |
There was a problem hiding this comment.
These are the old NTSC/PAL luminance weights. They should probably be the Rec. 709 luminance weights. I recommend labelling them as such so that they will be easy to adapt to other colour primaries in the future (godotengine/godot-proposals#12783):
| return sqrt(dot(rgb, vec3(0.299, 0.587, 0.114))); | |
| const vec3 rec709_luminance_weights = vec3(0.2126, 0.7152, 0.0722); | |
| return sqrt(dot(rgb, rec709_luminance_weights)); |
(I understand that Mobile and Foward+ use these incorrect weights as well. Eventually, I plan to open a PR to fix up all of these, but you're welcome to change over whichever you'd like in the mean time.
There was a problem hiding this comment.
Done for Compatibility. Should I also change them in Forward+/Mobile in this PR, or wait for a separate PR?
There was a problem hiding this comment.
Since the tonemap.glsl and tonemap_mobile.glsl files are being touched to introduce the combined_luminance_multiplier optimization, I'd say you might as well go ahead and update the luminance weights there so that all files will stay in-sync with each other.
|
Additionally, all three copies of In post.glsl: float combined_luminance_multiplier = exposure / luminance_multiplier;In tonemap.glsl and tonemap_mobile.glsl: float combined_luminance_multiplier = exposure * params.luminance_multiplier;And then in all three files, replace all |
6bd74b3 to
9063d02
Compare
|
I've applied the changes/optimizations above and tested it on all renderers. |
I just tried a bit more with this: it seems that |
9063d02 to
2f66d2e
Compare
allenwp
left a comment
There was a problem hiding this comment.
I see that you've set apply_color_adjustments_in_post to true, but it does not seem to be active with 2D rendering, even when an Environment has been added with a background mode of Canvas
Is this intentional? (I haven't looked into whether this is normal for Godot or not, so maybe this makes sense?)
|
|
|
Rebased and tested again, it works as expected. Thanks @allenwp for the feedback 🙂
This is probably intentional. We generally don't want FXAA to apply to 2D rendering, as it'll make it look very blurry (small text becomes almost unreadable). SMAA doesn't hurt 2D rendering as badly, but it's still not ideal. PS: I can't download the project you linked (
Being able to adjust FXAA (or SMAA) parameters should be discussed in its own proposal. If it's implemented, it should also be done in Forward+ and Mobile. |
2f66d2e to
0272d2c
Compare
0272d2c to
3f2b574
Compare
3f2b574 to
126655e
Compare
|
Tested locally, it works as expected on desktop hardware Testing project: The shader fails to compile on web (or any OpenGL ES 3 backend) with the following error: float QUALITY(float q) {
return (q < 5 ? 1.0 : (q > 5 ? (q < 10 ? 2.0 : (q < 11 ? 4.0 : 8.0)) : 1.5));
}This next part isn't inherently related to this PR, just something I've noticed.
I personally don't consider this a blocking issue, since the same effect happens on the master branch with SSAO enabled. Just something to keep in mind. |




This adds FXAA support to the Compatibility renderer, making it have parity with Godot 3.x GLES3/GLES2 on this aspect.
When attempting to use SMAA in Compatibility (which isn't currently implemented), it will now fall back to FXAA to provide an experience as close as possible.
SMAA support could be added in a future PR (OpenGL ES 3.0 and WebGL 2.0 can support it), but it's more involved.
Testing project: test_screen_space_aa.zip
Preview
No glow, no SSAO
The first image has the separate tonemap pass disabled, as we don't use any effect that requires it (and
scaling_3d_scaleis1.0). There is a slight color shift as soon as the separate tonemap pass kicks in, but this also happens inmasterwith no FXAA.Glow + SSAO
Glow + SSAO + AgX tonemapping
TODO