LYGIA Shader Library

destinationOver (lygia/color/composite/destinationOver)

Porter Duff Destination Over Compositing

Use:

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

Check it on Github


#ifndef FNC_COMPOSITE_DST_OVER
#define FNC_COMPOSITE_DST_OVER

float compositeDestinationOver(float src, float dst) {
    return dst + src * (1.0 - dst);
}

vec3 compositeDestinationOver(vec3 srcColor, vec3 dstColor, float srcAlpha, float dstAlpha) {
    return dstColor + srcColor * (1.0 - dstAlpha);
}

vec4 compositeDestinationOver(vec4 srcColor, vec4 dstColor) {
    vec4 result = vec4(0.0);

    result.rgb = compositeDestinationOver(srcColor.rgb, dstColor.rgb, srcColor.a, dstColor.a);
    result.a = compositeDestinationOver(srcColor.a, dstColor.a);

    return result;
}
#endif

Use:

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

Check it on Github


#ifndef FNC_COMPOSITE_DST_OVER
#define FNC_COMPOSITE_DST_OVER

float compositeDestinationOver(float src, float dst) {
    return dst + src * (1.0 - dst);
}

float3 compositeDestinationOver(float3 srcColor, float3 dstColor, float srcAlpha, float dstAlpha) {
    return dstColor + srcColor * (1.0 - dstAlpha);
}

float4 compositeDestinationOver(float4 srcColor, float4 dstColor) {
    float4 result;

    result.rgb = compositeDestinationOver(srcColor.rgb, dstColor.rgb, srcColor.a, dstColor.a);
    result.a = compositeDestinationOver(srcColor.a, dstColor.a);

    return result;
}
#endif

Use:

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

Check it on Github


#ifndef FNC_COMPOSITE_DST_OVER
#define FNC_COMPOSITE_DST_OVER

float compositeDestinationOver(float src, float dst)
{
    return dst + src * (1.0 - dst);
}

float3 compositeDestinationOver(float3 srcColor, float3 dstColor, float srcAlpha, float dstAlpha)
{
    return dstColor + srcColor * (1.0 - dstAlpha);
}

float4 compositeDestinationOver(float4 srcColor, float4 dstColor) 
{
    float4 result;

    result.rgb = compositeDestinationOver(srcColor.rgb, dstColor.rgb, srcColor.a, dstColor.a);
    result.a = compositeDestinationOver(srcColor.a, dstColor.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