Add blend mode that sums alphas and does alpha blending for colors

This commit is contained in:
Riccardo Balbo 2019-03-08 18:34:37 +01:00 committed by Stephen Gold
parent 784106e0c6
commit 3851c35f08
2 changed files with 19 additions and 0 deletions

View File

@ -303,6 +303,17 @@ public class RenderState implements Cloneable, Savable {
* (1 - Source Alpha) * Dest Color -> (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) * (1 - Source Alpha) * Dest Color -> (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
*/ */
Alpha, Alpha,
/**
* Alpha blending, interpolates to source color from dest color
* using source alpha.
* The resulting alpha is the sum between the source alpha and the destination alpha.
* <p>
* Result.rgb = Source Alpha * Source Color +
* (1 - Source Alpha) * Dest Color -> (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
* Result.a = 1 * Source Alpha + 1 * Dest Alpha -> (GL_ONE, GL_ONE)
*
*/
AlphaSumA,
/** /**
* Multiplies the source and dest colors. * Multiplies the source and dest colors.
* <p> * <p>

View File

@ -789,6 +789,14 @@ public final class GLRenderer implements Renderer {
case Alpha: case Alpha:
blendFunc(RenderState.BlendFunc.Src_Alpha, RenderState.BlendFunc.One_Minus_Src_Alpha); blendFunc(RenderState.BlendFunc.Src_Alpha, RenderState.BlendFunc.One_Minus_Src_Alpha);
break; break;
case AlphaSumA:
blendFuncSeparate(
RenderState.BlendFunc.Src_Alpha,
RenderState.BlendFunc.One_Minus_Src_Alpha,
RenderState.BlendFunc.One,
RenderState.BlendFunc.One
);
break;
case PremultAlpha: case PremultAlpha:
blendFunc(RenderState.BlendFunc.One, RenderState.BlendFunc.One_Minus_Src_Alpha); blendFunc(RenderState.BlendFunc.One, RenderState.BlendFunc.One_Minus_Src_Alpha);
break; break;