jp9000 e1e21c01d5 obs-transitions: Convert premultiplied alpha to straight
In transitions, because the 'to' and 'from' are always rendered to
textures, the end result will always have premultiplied alpha.  This
would cause alpha to have blackish edges during transition, and cause
semi-transparent images to appear darker than they were supposed to.

To replicate, simply set the transparency of a source to 50%, then
transition between that scene and another scene.  The source will appear
to "pop" in and out unnaturally due to the premultiplied alpha effect of
the render targets.

To fix this, the solution is to simply convert premultiplied alpha to
straight alpha in the transition pixel shaders.
2017-02-06 13:22:51 -08:00

10 lines
162 B
C++

float4 convert_pmalpha(float4 color)
{
float4 ret = color;
if (color.a >= 0.001)
ret.xyz /= color.a;
else
ret = float4(0.0, 0.0, 0.0, 0.0);
return ret;
}