Add SSAA with SSIM-based perceptual downscaling #13959
Open
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.
Super-sampling anti-aliasing with a conventional downscaling algorithm smoothes the image, which is a disadvantage compared to disabled anti-aliasing. The SSIM-based perceptual downscaling algorithm tackles this problem and it parallelises well on the GPU.
The new SSAA method can be enabled with the anti aliasing setting and it is the slowest anti-aliasing technique now.
additional_images.7z.zip
For more pictures and information about the algorithm, see #6976 and the Perceptually Based Downscaling of Images paper.
Closes #6976
Related roadmap goal: 2.1 Rendering/Graphics improvements
How to test
On GNU/Linux with X11, it is possible to render everything shown on the screen with a smaller resolution and upscale it with nearest neighbour scaling by an integer factor:
xrandr --output CHANGE_THIS --transform 0.5,0,0,0,0.5,0,0,0,1 --filter nearest
(here it's 2x upscaling).This may help testing the anti-aliasing on a high resolution screen.
In Minetest the new SSAA method can be tested by setting the anti-aliasing setting to
antialiasing = ssaa_ssim_based
and playing around with different scales (fsaa
setting).By setting
gl_FragColor = vec4(ycbcr_to_linear_srgb(col_l), 1.0);
inclient/shaders/ssaa_ssim_based_3/opengl_fragment.glsl
, the algorithm behaves like the current smooth SSAA in Minetest except that it uses gamma-correct scaling.Note that the new SSAA method also preserves details which may be undesired, for example Moire artifacts if mip mapping is disabled.
Strange behaviour with tonemapping
If tonemapping is enabled, strange artifacts appear with
![screenshot_20231214_183454](https://private-user-images.githubusercontent.com/3192173/290607716-b5259ffc-8f58-4734-bd04-5d549043cdc1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MDA0NDksIm5iZiI6MTczOTYwMDE0OSwicGF0aCI6Ii8zMTkyMTczLzI5MDYwNzcxNi1iNTI1OWZmYy04ZjU4LTQ3MzQtYmQwNC01ZDU0OTA0M2NkYzEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTVUMDYxNTQ5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ODU4YTY5NmVhMzM4MWRhZGYwZmMwZmI4NzFjMGVkOTgyNmJlODZhZWIyOWEyYWZhMWY1N2MwZmM0OWM3ZGY0MyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.51tIPjRYhivrw7h-tRI739kYvOxO950FSWAqkTaJMIw)
testnodes:generated_png_ck
:With other nodes or without tonemapping, it looks fine.
Perhaps the problem wouldn't appear if the downscaling was applied after tonemapping instead of before.
We can ignore this behaviour because tonemapping in Minetest is a questionable feature anyway as the tonemapping input is already in SDR.