Last active
January 16, 2016 21:53
-
-
Save Madsy/dded8b4c8d8afb398e29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| With glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA), scaling both source and destination with the same factor: | |
| Note that: | |
| (src*a*k) + (dst*(1-a)*k) = ((src*a) + (dst*(1-a)))*k | |
| But since k is a part of a, we have to do some trickery: | |
| alpha = (1.0 - (1.0 - alpha)*factor) | |
| alpha = 1.0 - (factor - alpha*factor) | |
| alpha = 1.0 + (alpha-1)*factor | |
| So the fragment shader code becomes: | |
| color_out = vec4(color); | |
| color_out.rgb = color_out.rgb*vec3(factor); | |
| color_out.a = 1.0 + (color_out.a - 1.0)*factor; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment