-
Notifications
You must be signed in to change notification settings - Fork 437
Additive blend without drawcall #5551
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
base: master
Are you sure you want to change the base?
Conversation
I think this looks like a pretty good direction to take things, but will note that osu.Framework.Tests.2022-11-30.at.07.48.25.mp4 |
This bug existed before this PR already and probably did not have visible effects in the past. However, overlapping objects with an alpha channel, blended in mixture mode, should now have more correct transparency.
1. Alpha unmultiplication didn't work for fully additive textures (due to their alpha being zero), which is fixed by a minimum, non-zero, alpha value. 2. Alpha unmultiplication didn't occur in sRGB space (which, physically, it shouldn't, but osu! wants blending to happen in sRGB space)
Fixed! This problem shed light on a few problems osu! has with its blending in general. A few of those, I could fix and should make the game look slightly more correct looking forward. A few others of those are too late to be adjusted (or shouldn't be adjusted for aesthetic reasons, such as the design decision to do most, but not all, blending in sRGB space), so I added workarounds for these, along with verbose comments. |
Moves the distinction between "Additive" and "Mixture" blend modes into the shader. This is controlled by the sign bit of each vertex's alpha channel, which feels slightly hacky, but is the least-intrusive solution I could think of. (And it's basically free, perf-wise.)
A necessary component of this change is the use of premultiplied alpha in the shader outputs, which means that buffered containers need special treatment: their framebuffers become textures with premultiplied alpha, which needs to be unmultiplied further down the line (for backwards compatibility). In this PR, this is handled by an additional shader uniform that denotes whether the input texture has premultiplied alpha or not.
Another thing of note: in the interest of API compatibility, additive blending on the
Drawable
side is controlled by an extra boolean withinBlendingParameters
, which feels hacky. I'd prefer removing the distinction between additive and mixture blend modes as far as the graphics API is concerned... but that'd require changing every single place where additive blending is currently set.Lastly: some
osu-resources
-side shaders also need to have their output multiplied by alpha. I can make another PR for those -- it's a minor change. Until then, isolated places like osu!'s intro shader look broken.