-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Add a debanding property to Viewport #38097
Conversation
Strangely enough, I can notice much more banding when debanding is enabled on my laptop monitor (when looking at the screenshots at 1:1 scale). I don't know why exactly. Maybe this is because the laptop monitor's panel is 6-bit + FRC instead of true 8-bit, and that doesn't play well with checkerboard dithering? My desktop monitor is an AOC CQ32G1, for reference. |
This looks like a good start, though I've recently learned that there are much more sophisticated dithering algorithms out there which can result in much better performance and image quality Thanks to @s-ilent for bringing this to my attention |
@SaracenOne yea, we should probably use triangular noise instead of a fixed pattern to dither. |
b6fae4b
to
076ce32
Compare
It can be enabled in the Project Settings (`rendering/quality/screen_filters/use_debanding`). It's disabled by default as it has a small performance impact and can make PNG screenshots much larger (due to how dithering works). It will also slightly brighten the scene's dark areas. As a result, it should be enabled only when banding is noticeable enough. This closes godotengine#17006.
076ce32
to
8891579
Compare
I reworked this pull request to use the Portal 2 VR debanding algorithm. See the new slider comparison: https://imgsli.com/MjA0NjI |
This shouldn't have been merged while CI doesn't pass... it's actually bogus:
This makes all subsequent commits fail CI checks too. I'll push a fix (7480a7d). |
It's gonna require an algorithm change, but I don't like how obvious the dithering is due to its uniform distribution (brightened for visibility:) (I can't tell you how usable this code may be, but it appears to get the job done: https://www.shadertoy.com/view/MdVfz3) |
@hoontee there is indeed a bit of a repeating pattern. But under normal viewing circumstances it is not really detectable. Note, the technique was developed for VR where people would be very sensitive to such things. That being said, I experimented a bit and using a gradient noise indeed resulted in much more natural looking dithering. Note: youll want to turn your brightness up and open these screenshots in a tab with a dark background to really see the difference This PR (looks great unless you zoom very close, or increase contrast)Code for procedural gradient noise
|
@clayjohn That gradient noise would be much better for the engine. If your debanding code causes a different type of banding, then it doesn't matter how fast it is; it's useless. Going a step further, would it make sense to incorporate TIME into the noise function? |
Keep in mind that in most games, banding isn't that noticeable. It might more noticeable during the prototyping stage, but as long as you do your work on the art direction side, most banding will probably no longer be noticeable by the time your game is ready to ship. Perfect is the enemy of good 🙂 Many times, you might not need a debanding shader at all in a game with photorealistic materials. Banding usually becomes more noticeable in games that use a low-poly art style and simple, cartoony textures. I believe that in real world use cases, the current debanding shader is more than adequate. Performance matters for this kind of thing, as you generally want to always enable debanding no matter the target hardware. PS: Remember that when you artificially brighten an image using an image editor, it'll always have noticeable banding unless the image was saved with an HDR color depth (> 8 bpc). |
It was noticeable at original resolution on my monitor. Maybe you can add a debanding quality project setting? (Off / Performance / Quality drop-down) |
That means we have more code to maintain (and possibly backport, since I plan to backport this to the I'd prefer seeing significant demand from players to improve the debanding quality if they manage to notice the current dithering pattern in real gameplay 🙂 If we have enough demand for this, then we can consider adding an option to improve debanding quality. |
It can be enabled in the Project Settings (
rendering/quality/screen_filters/use_debanding
). It's disabled by default as it has a small performance impact and can make PNG screenshots much larger (due to how dithering works).Debanding will also slightly brighten the scene's dark areas – we should try to fix this if possible. Help is welcome in that area 🙂
Like MSAA, toggling the debanding setting in the Project Settings will apply to the editor viewport immediately, without having to restart the editor.
This closes #17006.
Preview
View slider comparisons on Imgsli