-
-
Notifications
You must be signed in to change notification settings - Fork 443
Add multiplicative blending #7868
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 multiplicative blending #7868
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7868 +/- ##
==========================================
+ Coverage 92.91% 92.93% +0.02%
==========================================
Files 641 641
Lines 60615 60616 +1
==========================================
+ Hits 56319 56336 +17
+ Misses 4296 4280 -16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it! Works intuitively and is a nice simple feature.
Would be great to add this as an example. I think users will have difficulty conceptualizing how it should look -- so an example would help get that across.
Your PR description is sufficient, just needs the example formatting. I can add in a follow-up PR if desired.
I don't know, seems a bit excessive to have an example for just a blending mode? Unless we add one with several blending modes side by side? Either way, maybe let's do this in a followp PR, yeah :) |
+1 to a gallery example, preferably a realistic one (e.g. some kind of probability map), +1 for new PR. |
'cull_face': False, | ||
'blend': True, | ||
'blend_func': ('dst_color', 'zero', 'one', 'one'), | ||
'blend_equation': 'func_add', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brisvag can you explain to me how this work? The func_add
really threw me. 😂
what are the contents of the blend_func
tuple?
Maybe a comment here would be interesting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's trippy, yeah. I learned from https://www.khronos.org/opengl/wiki/Blending#Blending_Parameters
Maybe I'll just put a link, cause this requires some background.
The relevant bits are:
Blending equation:
* Orgb = srgb * Srgb + drgb * Drgb
* Oa = sa * Sa + da * Da
(O = origin, D = destination, small is parameter, capitalized is the value itself)
"For example, if the blending you want is a straight multiplication of the source and destination colors, O = S * D, then you should set the GL_FUNC_ADD function. Then set the source parameter for that equation to GL_DST_COLOR, and set the destination parameter to GL_ZERO (we don't want to do addition, so null out the additive term). This will give O = D * S + 0 * D. "
Basically, we're using the destination color as a parameter for the origin color, and ignoring the destination color itself because it's already accounted for.
This PR made me realize something that applies to
|
We can introduce it somehow, it currently does nothing because of the
Makes sense to me, no strong opinions :P
Yes, very important in 3D: try the cells3d example and switch both layers to translucent. Especially imortant for plane rendering. |
References and relevant issues
Description
Add multiplicative blending to our blending modes.
This can be useful in several scenarios, such as the example from the above discussion: