e1e21c01d5
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.
42 lines
781 B
Plaintext
42 lines
781 B
Plaintext
uniform float4x4 ViewProj;
|
|
uniform texture2d tex_a;
|
|
uniform texture2d tex_b;
|
|
uniform float fade_val;
|
|
|
|
sampler_state textureSampler {
|
|
Filter = Linear;
|
|
AddressU = Clamp;
|
|
AddressV = Clamp;
|
|
};
|
|
|
|
struct VertData {
|
|
float4 pos : POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
};
|
|
|
|
#include "premultiplied.inc"
|
|
|
|
VertData VSDefault(VertData v_in)
|
|
{
|
|
VertData vert_out;
|
|
vert_out.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj);
|
|
vert_out.uv = v_in.uv;
|
|
return vert_out;
|
|
}
|
|
|
|
float4 PSFade(VertData v_in) : TARGET
|
|
{
|
|
float4 a_val = convert_pmalpha(tex_a.Sample(textureSampler, v_in.uv));
|
|
float4 b_val = convert_pmalpha(tex_b.Sample(textureSampler, v_in.uv));
|
|
return lerp(a_val, b_val, fade_val);
|
|
}
|
|
|
|
technique Fade
|
|
{
|
|
pass
|
|
{
|
|
vertex_shader = VSDefault(v_in);
|
|
pixel_shader = PSFade(v_in);
|
|
}
|
|
}
|