-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Multiple blending fixes & improvements #2921
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
Conversation
O = D - (S * SA) now matches Java2D
O = D * S now matches Java2D
OA = SA + DA for all modes now matches Java2D
|
Hello Jakub, this is amazing, thanks once again for all your work. All the fixes look good, but I have a question with the SUBTRACT mode. O = sD - dS By doing pgl.blendFuncSeparate(PGL.SRC_ALPHA, PGL.ONE, PGL.ONE, PGL.ONE); we are setting s = SA and d = 1, if I'm not mistaken, which would lead to O = D * SA - S instead of O = D - (S * SA) Am I missing something? |
|
The OpenGL wiki seems to be misleading, because the glBlendEquation docs specify this to be O = dD - sS The test pattern I used supports this. Honestly I spent a lot of time on that wiki page, but didn't notice the parameters were swapped and I also didn't check the docs. I just swapped it because parameter names are (srcRGB, dstRGB, srcAlpha, dstAlpha). |
|
Yes, O = dD - sS is what makes sense and it is in the glBlendEquation doc, so it is definitely a typo in the wiki. I think this is ready for merging... @benfry This PR makes some changes to the blending in PGraphicsJava2D, basically the source and destination colors are inverted. I looked at the code and seems that the fix from Jakub is correct, just wanted to check with you since I'm not very familiar with the image manipulations in Java2D. |
|
Looks good on a quick glance—I'll go ahead and merge. We really appreciate you looking into this @JakubValtar. This sort of thing (digging into the issue, testing it across renderers) is a huge help. |
Multiple blending fixes & improvements
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Java2D
OpenGL
Alpha 255

Alpha 80 (other modes than REPLACE, BLEND, ADD and SUBTRACT are not comparable as JAVA2D uses SRC alpha to interpolate between DST and OUTPUT, OpenGL just uses OUTPUT)

Test code: