1
0
mirror of synced 2024-11-30 16:54:30 +01:00

Merge overlay blend mode fix from ARCHVILE.

This commit is contained in:
Jennifer Taylor 2021-10-24 15:51:08 +00:00
parent a97df7d24a
commit 2664237026
2 changed files with 6 additions and 10 deletions

View File

@ -131,12 +131,10 @@ def blend_overlay(
# jubeat uses the alternative formula Src * Dst + Dst * (1 - As). # jubeat uses the alternative formula Src * Dst + Dst * (1 - As).
# Calculate final color blending. # Calculate final color blending.
src_alpha = src[3] / 255.0
src_remainder = 1.0 - src_alpha
return ( return (
clamp((255 * (2.0 * (dest[0] / 255.0) * (src[0] / 255.0) * src_alpha)) + (dest[0] * src_remainder)), clamp((255 * (2.0 * (dest[0] / 255.0) * (src[0] / 255.0)))),
clamp((255 * (2.0 * (dest[1] / 255.0) * (src[1] / 255.0) * src_alpha)) + (dest[1] * src_remainder)), clamp((255 * (2.0 * (dest[1] / 255.0) * (src[1] / 255.0)))),
clamp((255 * (2.0 * (dest[2] / 255.0) * (src[2] / 255.0) * src_alpha)) + (dest[2] * src_remainder)), clamp((255 * (2.0 * (dest[2] / 255.0) * (src[2] / 255.0)))),
dest[3], dest[3],
) )

View File

@ -204,12 +204,10 @@ extern "C"
// jubeat uses the alternative formula Src * Dst + Dst * (1 - As). // jubeat uses the alternative formula Src * Dst + Dst * (1 - As).
// Calculate final color blending. // Calculate final color blending.
double src_alpha = src.a / 255.0;
double src_remainder = 1.0 - src_alpha;
return (intcolor_t){ return (intcolor_t){
clamp((255 * (2.0 * (dest.r / 255.0) * (src.r / 255.0) * src_alpha)) + (dest.r * src_remainder)), clamp((255 * (2.0 * (dest.r / 255.0) * (src.r / 255.0)))),
clamp((255 * (2.0 * (dest.g / 255.0) * (src.g / 255.0) * src_alpha)) + (dest.g * src_remainder)), clamp((255 * (2.0 * (dest.g / 255.0) * (src.g / 255.0)))),
clamp((255 * (2.0 * (dest.b / 255.0) * (src.b / 255.0) * src_alpha)) + (dest.b * src_remainder)), clamp((255 * (2.0 * (dest.b / 255.0) * (src.b / 255.0)))),
dest.a, dest.a,
}; };
} }