lygia
/color
/composite
/sourceAtop
)Porter Duff Source Atop Compositing
Use:
<vec4> compositeSourceAtop(<vec4> src, <vec4> dst)
#ifndef FNC_COMPOSITE_SRC_ATOP
#define FNC_COMPOSITE_SRC_ATOP
float compositeSourceAtop(float src, float dst) {
return src * dst + dst * (1.0 - src);
}
vec3 compositeSourceAtop(vec3 srcColor, vec3 dstColor, float srcAlpha, float dstAlpha) {
return srcColor * dstAlpha + dstColor * (1.0 - srcAlpha);
}
vec4 compositeSourceAtop(vec4 srcColor, vec4 dstColor) {
vec4 result = vec4(0.0);
result.rgb = compositeSourceAtop(srcColor.rgb, dstColor.rgb, srcColor.a, dstColor.a);
result.a = compositeSourceAtop(srcColor.a, dstColor.a);
return result;
}
#endif
Use:
<float4> compositeSourceAtop(<float4> src, <float4> dst)
#ifndef FNC_COMPOSITE_SRC_ATOP
#define FNC_COMPOSITE_SRC_ATOP
float compositeSourceAtop(float src, float dst) {
return src * dst + dst * (1.0 - src);
}
float3 compositeSourceAtop(float3 srcColor, float3 dstColor, float srcAlpha, float dstAlpha) {
return srcColor * dstAlpha + dstColor * (1.0 - srcAlpha);
}
float4 compositeSourceAtop(float4 srcColor, float4 dstColor) {
float4 result;
result.rgb = compositeSourceAtop(srcColor.rgb, dstColor.rgb, srcColor.a, dstColor.a);
result.a = compositeSourceAtop(srcColor.a, dstColor.a);
return result;
}
#endif
Use:
<float4> compositeSourceAtop(<float4> src, <float4> dst)
#ifndef FNC_COMPOSITE_SRC_ATOP
#define FNC_COMPOSITE_SRC_ATOP
float compositeSourceAtop(float src, float dst)
{
return src * dst + dst * (1.0 - src);
}
float3 compositeSourceAtop(float3 srcColor, float3 dstColor, float srcAlpha, float dstAlpha)
{
return srcColor * dstAlpha + dstColor * (1.0 - srcAlpha);
}
float4 compositeSourceAtop(float4 srcColor, float4 dstColor)
{
float4 result;
result.rgb = compositeSourceAtop(srcColor.rgb, dstColor.rgb, srcColor.a, dstColor.a);
result.a = compositeSourceAtop(srcColor.a, dstColor.a);
return result;
}
#endif
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.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository