3

Normally when you do SpriteBatch.Draw you can specify a color. But here's the problem. If I use custom shaders they ignore color passed by SpriteBatch.Draw...

How do I take that into account? I mean how exactly SpriteBatch.Draw passes a color? If I know it I can use it in my shader.

So far what I have (relevant part):

float4 NoEffects(float2 coords: TEXCOORD0) : COLOR0
{
    return tex2D(s0, coords);
}

technique Default
{
    pass Pass1
    {
        PixelShader = compile ps_2_0 NoEffects();
    }
}
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
NewProger
  • 2,945
  • 9
  • 40
  • 58

2 Answers2

4

You need to retrieve the color that's passed through the vertex shader and use it when calculating your final output:

float4 NoEffects(float4 color : COLOR0, float2 coords : TEXCOORD0) : COLOR0
{
    return tex2D(s0, coords) * color;
}
Cole Campbell
  • 4,846
  • 1
  • 17
  • 20
0

You can use an EffectParameter to pass a value to your effect.

http://msdn.microsoft.com/en-us/library/bb976060.aspx

Tergiver
  • 14,171
  • 3
  • 41
  • 68
  • 1
    Thank you for the advice, but I know that already, obivously... What I would like do, as I described in the question, is to use the color passed by SpriteBatch.Draw(); instead of passing it myself again. – NewProger Jan 02 '13 at 18:38