LYGIA Shader Library

vividLightSourceOver (lygia/color/layer/vividLightSourceOver)

Vivid Light Blending with Porter Duff Source Over Compositing

Dependencies:

Use:

<vec4> layerVividLightSourceOver(<vec4> src, <vec4> dst)

Check it on Github



#ifndef FNC_LAYER_VIVID_LIGHT_SRC_OVER
#define FNC_LAYER_VIVID_LIGHT_SRC_OVER

vec4 layerVividLightSourceOver(vec4 src, vec4 dest) {
    vec4 result = vec4(0.0, 0.0, 0.0, 0.0);

    // Compute vivid light for RGB channels
    vec3 blendedColor = blendVividLight(src.rgb, dest.rgb);

    // Compute source-over for RGB channels
    result.rgb = compositeSourceOver(blendedColor, dest.rgb, src.a, dest.a);

    // Compute source-over for the alpha channel
    result.a = compositeSourceOver(src.a, dest.a);

    return result;
}
#endif

Dependencies:

Use:

<float4> layerVividLightSourceOver(<float4> src, <float4> dst)

Check it on Github



#ifndef FNC_LAYER_VIVID_LIGHT_SRC_OVER
#define FNC_LAYER_VIVID_LIGHT_SRC_OVER

float4 layerVividLightSourceOver(float4 src, float4 dest) {
    float4 result = float4(0.0, 0.0, 0.0, 0.0);

    // Compute vivid light for RGB channels
    float3 blendedColor = blendVividLight(src.rgb, dest.rgb);

    // Compute source-over for RGB channels
    result.rgb = compositeSourceOver(blendedColor, dest.rgb, src.a, dest.a);

    // Compute source-over for the alpha channel
    result.a = compositeSourceOver(src.a, dest.a);

    return result;
}
#endif

Dependencies:

Use:

<float4> layerVividLightSourceOver(<float4> src, <float4> dst)

Check it on Github



#ifndef FNC_LAYER_VIVID_LIGHT_SRC_OVER
#define FNC_LAYER_VIVID_LIGHT_SRC_OVER

float4 layerVividLightSourceOver(float4 src, float4 dest)
{    
    float4 result;

    // Compute vivid light for RGB channels
    float3 blendedColor = blendVividLight(src.rgb, dest.rgb);

    // Compute source-over for RGB channels
    result.rgb = compositeSourceOver(blendedColor, dest.rgb, src.a, dest.a);

    // Compute source-over for the alpha channel
    result.a = compositeSourceOver(src.a, dest.a);

    return result;
}
#endif

Licenses

LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.

Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).

It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.

Get the latest news and releases

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository