X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=overlay_effect.frag;h=d32cc062204c4492dbb552c6930908e2f8b805be;hp=36c1a7996cf48e0112908d93aa1b9634698ed2fa;hb=009c7510df1ac1b70662b0085ebaf1a619dd761a;hpb=b10c546f579c7ccb5939161e61a71cd18a3f9bbd diff --git a/overlay_effect.frag b/overlay_effect.frag index 36c1a79..d32cc06 100644 --- a/overlay_effect.frag +++ b/overlay_effect.frag @@ -13,24 +13,15 @@ // C_o without the division by alpha_o). vec4 FUNCNAME(vec2 tc) { +// SWAP_INPUTS will be #defined to 1 if we want to swap the two inputs, +#if SWAP_INPUTS + vec4 bottom = INPUT2(tc); + vec4 top = INPUT1(tc); +#else vec4 bottom = INPUT1(tc); vec4 top = INPUT2(tc); -#if 0 - // Postmultiplied version. - float new_alpha = mix(bottom.a, 1.0, top.a); - if (new_alpha < 1e-6) { - // new_alpha = 0 only if top.a = bottom.a = 0, at least as long as - // both alphas are within range. (If they're not, the result is not - // meaningful anyway.) And if new_alpha = 0, we don't really have - // any meaningful output anyway, so just set it to zero instead of - // getting division-by-zero below. - return vec4(0.0); - } else { - vec3 premultiplied_color = mix(bottom.rgb * bottom.aaa, top.rgb, top.a); - vec3 color = premultiplied_color / new_alpha; - return vec4(color.r, color.g, color.b, new_alpha); - } -#else - return top + (1.0 - top.a) * bottom; #endif + return top + (1.0 - top.a) * bottom; } + +#undef SWAP_INPUTS