-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Oversampling without smoothing #6976
Comments
Remember that even 2× SSAA is very expensive, as it requires rendering four times the original amount of pixels. For example, to output to a 1920×1080 window, you need to render in 3840×2160. Since most people with high-end graphics cards have displays with a resolution higher than 1920×1080, it's going to be even worse for them – keeping above 60 FPS will become difficult on crowded worlds. |
You're right, I think there're also graphic chips which don't support rendering at very high resolution. |
Those graphics cards would be too slow to render high resolutions at playable framerates anyway. |
please respect the new issue template... |
Some of the template sections will be irrelevant for some issues. Version / OS / hardware is mostly for bugs. |
I thought about adding a configurable threshold resolution, oversampling is automatically en-/disabled when changing the window resolution. |
Issue seems useful to keep open for consideration. |
I still like the idea of enabling SSAA manually with a setting like |
Properly configured Anisotropic Filtering is free |
@devshgraphicsprogramming Anisotropic filtering doesn't solve this issue fully when using nearest-neighbor interpolated textures 🙂 Remember that MSAA also only operates on geometry, it doesn't affect the "insides" of textures. |
OpenGL has two texture filtering modes that can be set separately (which irrlicht doesn't expose):
you could set mag filter to NEARST, and min to LINEAR_MIPMAP_LINEAR Also Irrlicht SVN maybe has direct mip-map control, what @HybridDog is proposing is simply generating all the mip-maps properly (offline) with nice filters and uploading them explicitly instead of relying on OpenGL mipmap generation hints to do the work for you from the base level. There's lots of tools (GIMP, Nvidiai Texture Tools, AMD Compressonator) that willl generate mip-maps of textures for you with nice filters like Lanczos or Kalman (or Kelemen, don't remember how its spelt) MSAA has nothing to do with this, also MSAA is an arcane technique that belongs to the 2000s |
Does Minetest use LINEAR_MIPMAP_NEAREST when mipmapping is enabled (and the magnification filter is NEAREST)?
That's another issue: #6917 |
I have implemented the oversampling with shaders in an opengl example program: I don't know how to put this into minetest, which uses Irrlicht. The code changes could involve rendering in a higher resolution (minetest already has an undersampling setting, where it renders in lower resolution), and applying the downscaling shaders (this should be similar to adding post-processing). |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Interestingly, your changes to RenderingCorePlain are all that is necessary to add in an FXAA shader. grapereader@7ba37fe So that's fun 😅 Would be awesome if Minetest supported screen space post-processing more cleanly so it didn't have to be hacked in like this. But I digress. |
@grapereader I agree it would be nice to offer a built-in FXAA option, since it can look quite good at 1440p or 4K. Feel free to open a pull request for this 🙂 |
There's an abandoned Pull Request for post processing: #9895 |
I've been playing around some more and honestly, simple SSAA (as implemented here) works great at 1080p and should be an option in the base game. Since Minetest rendering is already so fast, I easily get 60fps despite the double size render. And it just looks beautiful. On the other hand people with 4K would probably want something faster like FXAA. That's also doable. I spent all night trying to get SMAA to work hoping that would be the one-size-fits-all solution but it's been a crap shoot. Pipeline works great up to and including edge detection but I can't get the damned thing to calculate weights properly. It's just too complex to grapple with. Oh well. Tested some other single-pass algorithms like DLAA, DDAA, NFAA. They work fine but FXAA is still king here. DDAA is a close second. Still, we need a generalized post-processing pipeline before any of this could be merged. I checked out #9895 (thanks for the link). It is on the right path. It adds a new RenderingCore, which is exactly how I would have done it. I don't know if the complaints against the additional 3D mode (which seem to have been the main blocker) are tenable without either:
At this point I'm not sure if I should be commenting here or on that PR. At least it is linked here, now, because it was mentioned. |
I have reimplemented SSAA with SSIM-based perceptual downscaling for the current Minetest version: https://github.com/HybridDog/minetest/tree/m_oversampling_new. By the way: I noticed that I've accidentally swapped the EOTF and OETF in the colour conversions before in my old implementation, so I've hidden the screenshots above now. No anti-aliasingSSAA currently available in MinetestThis image looks darker because downscaling is done without gamma correction. SSAA with SSIM-based perceptual downscalingAll YCbCr channels sharpenedOnly the Y channel sharpenedNo sharpeningThis should be the same as SSAA currently available in Minetest except that it has gamma correction. |
I've experimented with different colour spaces, different values for the numerical precision problem prevention, and tried mpv's shader. Effect of the chosen colour spaceIf I use linearised sRGB instead of linear YCbCr, visible colour fringes appear, such as blue pixels in the bricks and red pixels in the text which was originally just white on bright blue background. Downscaled text; image order: RGB, YCbCr, YCbCr with only Y sharpened Downscaled bricks; image order: RGB, YCbCr, YCbCr with only Y sharpened Effect of the threshold to prevent numerical errorsThere is a threshold which is required to prevent numerical errors. If the image is stored with 16 bit floats instead of 32 bit floats, I need to increase this threshold to 0.0005 to avoid artifacts, so a lower threshold requires more memory to store images. Downscaled text with different threshold values; image order (thresholds): 0.000001, 0.0005, 0.05: Downscaled bricks with different threshold values; image order (thresholds): 0.000001, 0.0005, 0.05: |
I've changed my implementation to use 0.000001 and sharpen only the Y channel and I think it looks better. A backup of the previous implementation which uses the 0.0005 thresholds and sharpens all YCbCr channels is now in my m_oversampling_ycbcr_all_channels branch. |
Issue type
Minetest version
OS / Hardware
Operating system: Lubuntu 17.10
CPU: intel
GPU model: intel graphics chip
OpenGL version: 4.5 (Core Profile) Mesa 17.4.0-devel - padoka PPA
Summary
I think the algorithm I tried for mipmapping (#6917) works great for oversampling.
Please view the screenshots in 1:1 resolution or with nearest neighbour upscaling (integer or big scaling factor).
nearest neighbour downscaled (corresponds most to no oversampling):
![nn](https://user-images.githubusercontent.com/3192173/35473747-d02a57b4-0384-11e8-8e27-2e3531bcd1b2.png)
![tulip_nn](https://user-images.githubusercontent.com/3192173/35473829-d461dd6a-0385-11e8-9b0b-91a7c64f8ce9.png)
ssim based downscaled:
![ssim](https://user-images.githubusercontent.com/3192173/35473772-3292e9de-0385-11e8-9fa8-01dda881ba31.png)
![tulip_ssim](https://user-images.githubusercontent.com/3192173/35473827-d0415170-0385-11e8-9c79-fef4d7b3fda5.png)
As you can see, oversampling with this downscaling algorithm
if mipmapping is used, there're more details instead of Moire effect reduction,
It can be implemented with parallelization (shaders), the speed of the algorithm lies between linear and bicubic downscaling.
Also, if implemented on the gpu it maybe doesn't have a noticeable performance impact because minetest is cpu-intensive.
A window resolution threshold setting could be added so that oversampling is only enabled when the resolution is low enough. 2x oversampling means four times as many pixels need to be rendered (in addition to the downscaling overhead) and fortunately oversampling is especially useful when the game is rendering for low resolution output.
Additional informations
Here is a list of some implementations of SSIM-based perceptual downscaling:
The text was updated successfully, but these errors were encountered: