Question

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();
    }
}
Was it helpful?

Solution

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;
}

OTHER TIPS

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top