/**
 * Copyright (C) 2014 Stellar Jockeys.
 * All Rights Reserved.
 *
 * NOTICE: All information contained herein is, and remains the property of
 * Stellar Jockeys and its suppliers, if any.  The intellectual and technical
 * concepts contained herein are proprietary to Stellar Jockeys and its suppliers.
 * Dissemination of this information or reproduction of this material is
 * strictly forbidden unless prior written permission is obtained from
 * Stellar Jockeys.
 *
 * @file fragblend.glsl
 * @date 07/15/2014
 */
#ifndef FRAGBLEND_GLSL
#define FRAGBLEND_GLSL

/**
 * @brief Adjusts the color based on its alpha depending on the blend mode.
 *
 * Allows simulating alpha blending with blend modes which do not support
 * it via the gl blend equation.
 *
 * Blend x Determines whether to blend the color with a background color
 * using the fragment alpha (color alpha * glyph texel alpha).
 * 0 for no blend. 1 for blending.
 *
 * Blend y Specifies the greyscale background color.
 *
 * Normal/Linear Dodge : <0,_>
 * Screen/Lighten      : <1,0>
 * Multiply/Darken     : <1,1>
 */
vec4 BlendedColor(in vec3 color, in float alpha, in vec2 blend)
{
    vec3 background = mix(color, blend.yyy, blend.x);

    return vec4(mix(background, color, alpha), alpha);
}

#endif // FRAGBLEND_GLSL
