filter-sdf-effects: Fix colored shadows changing image

Colored shadows previously had an effect on the image color, but this is incorrect if the image is fully opaque. This fixes it by using premultiplied alpha mixing instead.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2019-01-30 03:37:46 +01:00
parent 75009c617a
commit ecd17cff6c

View file

@ -118,11 +118,14 @@ float4 PS_SDFShadow_v1_1(VertDataOut v_in) : TARGET
float t1 = sdf_distance - _outer_min; float t1 = sdf_distance - _outer_min;
float t2 = clamp(t1 / delta, 0., 1.); float t2 = clamp(t1 / delta, 0., 1.);
final = lerp(final, _outer_color, 1. - t2); final = lerp(final, _outer_color, (1. - t2) * _outer_color.a);
} }
// Base Image // Base Image
final += base; if (base.a > 0.) {
float3 rgb = base.rgb / base.a;
final = lerp(final, base, base.a);
}
//! Inner Shadow //! Inner Shadow
// Are we allowed to draw an inner shadow? // Are we allowed to draw an inner shadow?