I have following shader file(.fx) and i am using this using DirectX/C#
float brightness;
float contrast;
sampler TextureSampler :register(s0);
float4 TextureColor(in float2 texCoord : TEXCOORD0) : COLOR
{
float4 texCol1 = tex2D(TextureSampler, texCoord);
float4 outColor = texCol1 + brightness;
outColor*=contrast;
return outColor;
}
technique TransformTexture
{
pass P0
{
CullMode = None;
PixelShader = compile ps_2_0 TextureColor();
}
}
it work fine when i was drawing my texture using vertex buffer like.
_effect.Technique = "TransformTexture";
//_effect.SetValue("Texture1", _text);
bHandle = _effect.GetParameter(null, "brightness");
cHandle = _effect.GetParameter(null, "contrast");
vertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionColoredTextured),
4,_device,Usage.WriteOnly,
CustomVertex.PositionColoredTextured.Format,Pool.Managed);
_effect.SetValue(bHandle,.5f);
_effect.SetValue(cHandle, .5f);
_effect.CommitChanges();
_device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1, 0);
_device.BeginScene();
_effect.Begin(0);
_effect.BeginPass(0);
if (texture != null)
{
_device.SetTexture(0, texture);
}
_device.SetStreamSource(0, vertexBuffer, 0);
_device.VertexFormat = CustomVertex.PositionColoredTextured.Format;
_device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
if (texture != null)
{
_device.SetTexture(0, null);
}
_effect.EndPass();
_effect.End();
_device.EndScene();
_device.Present(pnl1);
but it not showing any effect on my texture when i am drawing using sprite like
sprite=new sprite(device);
_device.BeginScene();
_effect.Begin(0);
_effect.BeginPass(0);
_sprite.Draw(_text, Vector3.Empty, Vector3.Empty, Color.White.ToArgb());
_sprite.End();
_effect.EndPass();
_effect.End();
_device.EndScene();
_device.Present(pnl1);
What i was doing wrong, please help me or any example or link of applying effect on sprite would be great.
Many Thank in advance