Here is an example transition pixel shader
float Progress;
texture Input1;
sampler Input1Sampler = sampler_state
{
Texture = <Input1>;
};
texture Input2;
sampler Input2Sampler = sampler_state
{
Texture = <Input2>;
};
float4 Fade(float2 uv)
{
float4 c1 = tex2D(Input1Sampler, uv);
float4 c2 = tex2D(Input2Sampler, uv);
return (lerp(c1, c2, Progress));
}
float4 main(float2 uv : TEXCOORD) : COLOR
{
return (Fade(uv));
}
technique FadeTransition
{
pass FadeTransition
{
VertexShader = null;
PixelShader = compile ps_2_0 main();
}
}
Here is how I apply itm_transitionEffect.Technique = m_transitionEffect.GetTechnique(0);
m_transitionEffect.SetTexture("Input1", m_screenTexture[0].DXTexture);
m_transitionEffect.SetTexture("Input2", m_screenTexture[1].DXTexture);
m_transitionEffect.SetValue<float>("Progress", m_progress);
m_transitionEffect.CommitChanges();
m_transitionEffect.Begin();
m_transitionEffect.BeginPass(0);
// Render stuff
m_transitionEffect.EndPass();
m_transitionEffect.End();
Here is an example effect pixel shadertexture SourceTexture;
sampler SourceTextureSampler = sampler_state
{
Texture = <SourceTexture>;
};
float4 InvertColorFunc(float2 tex : TEXCOORD) : COLOR
{
float4 texcolor = tex2D(SourceTextureSampler, tex);
float4 newcolor = 1.0f - texcolor;
return (float4(newcolor.rgb, texcolor.a));
}
technique InvertColor
{
pass InvertColor
{
VertexShader = null;
PixelShader = compile ps_2_0 InvertColorFunc();
}
}
Here is how I apply it.m_effectEffect.Technique = m_effectEffect.GetTechnique(0);
m_effectEffect.SetTexture("SourceTexture", m_screenTexture[0].DXTexture);
m_effectEffect.CommitChanges();
m_effectEffect.Begin();
m_effectEffect.BeginPass(0);
// Render stuff
m_effectEffect.EndPass();
m_effectEffect.End();
How can I combine these two shaders and keep them in separate files? I have tried nesting the two together but it does not seem to work.