I am trying to learn how to use Shaders for a 2D XNA project I am working on. To test them out, I was trying to make a white triangle become colored using a super simple Pixel Shader, and I can't get it to work.
This is my Pixel Shader:
float4 ThePixelShader(float4 texCoord : TEXCOORD0) : COLOR0
{
return(125,15,105,1);
}
technique MandelbrotSet
{
pass Pass0
{
PixelShader = compile ps_2_0 ThePixelShader();
}
}
And this is the code I was using to draw my Plain white triangle onto the screen, and trying to use the shader to change its color.
GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin();
//MandelbrotEffect.Parameters[""].SetValue();
MandelbrotEffect.CurrentTechnique = MandelbrotEffect.Techniques["MandelbrotSet"];
foreach (EffectPass pass in MandelbrotEffect.CurrentTechnique.Passes)
{
pass.Apply();
spriteBatch.Draw(Dot, new Rectangle(10, 10, 200, 200), Color.White);
}
spriteBatch.End();
I'm guessing I am doing something dumb, but I can't figure out what. The triangle is drawn on screen as just a plain white triangle, what it would look like without a shader.
EDIT: Changed my drawing code to look like this.
GraphicsDevice.Clear(Color.Black);
//MandelbrotEffect.Parameters[""].SetValue();
MandelbrotEffect.CurrentTechnique = MandelbrotEffect.Techniques["MandelbrotSet"];
spriteBatch.Begin(0, BlendState.Opaque, null, null, null, MandelbrotEffect);
spriteBatch.Draw(blank, Vector2.Zero, Color.White);
spriteBatch.End();
Now it does draws the box fullscreen, and I know the shader is working because changing the Alpha value does change the Alpha value of the full screen image, but still the colors don't change.
Thoughts?