I'm not sure if I'm not using the right SpriteBatch parameters or if my shader is not coded properly, but, to be simple, I'm trying to make a shader that sets the alpha of all pixels to 128. However, there seems to be only 2 possible 'alphas'. Either if I set the value to 0, nothing appears, and any other value will set the alpha to 255. There is absolutely no in-between and I can't put my finger on what's wrong. Here is the code around the draw call (I figured that, since I'm simply trying to set the alpha to 128 on everything, what I'm drawing is irrelevant)
m_GridFadeEffect.Parameters["FadeDistance"].SetValue(GridDrawRadius);
m_GridFadeEffect.Parameters["Center"].SetValue(Center);
m_GridFadeEffect.Parameters["LineColor"].SetValue(new Vector4(GridLinesColor.R, GridLinesColor.G, GridLinesColor.B, GridLinesColor.A));
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, m_GridFadeEffect);
// Draw here
spriteBatch.End();
And here is the shader
uniform extern float FadeDistance;
uniform extern float2 Center;
uniform extern float4 LineColor;
float4 PixelShaderFunction(float2 inCoord: TEXCOORD0) : COLOR0
{
float4 Return = LineColor;
Return.a = 128; // I also tried Return.a = 0.5f;
return Return;
}
technique
{
pass P0
{
PixelShader = compile ps_2_0 PixelShaderFunction();
}
}