I was messing around with some effect files, trying to make an effect that overlays every pixel of a sprite with a certain color, while maintaining its transparency. I wrote this HLSL file, but no matter what color I set the flashColor parameter to (using the effect.Parameters['flashColor'].SetValue(new Vector3(1,0,0)) method), the color the sprite gets drawn with is still white!
sampler TextureSampler : register(s0);
Float intensity;
float3 flashColor;
float4 main(float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
float4 tex = tex2D(TextureSampler, texCoord);
float4 newCol = (flashColor.r, flashColor.g, flashColor.b, color.a * tex.a);
float4 final = lerp(tex.rgba, newCol, intensity);
return final;
}
technique ToFlashColor
{
pass Pass1
{
PixelShader = compile ps_2_0 main();
}
}
Thanks in advance!

New Topic/Question
Reply



MultiQuote



|