Hey,
I tried to apply my shader but can’t get to work it with parameters. Is it supported in Mono Game now ?
spriteBatch.Begin(SpriteSortMode.Immediate,
BlendState.AlphaBlend,
null,
null,
null,
null,
camera.GetTransform());
if (isInMatrixMode)
{
shader.Parameters[“Param”].SetValue(0.7f);
shader.CurrentTechnique.Passes[0].Apply();
}
spriteBatch.Draw(Texture, Rect, animation.getSourceRect(), Color.White, 0, Vector2.Zero, SpriteEffects.None, 0);
spriteBatch.End();
This line is the problem:
shader.Parameters[“Param”].SetValue(0.7f);
My shader is really simple at it works fine with “hardcoded” parameters but it is useless without passing parameter in runtime. Any ideas ? I’m really stuck with this.
HLSL code looks like:
sampler TextureSampler;
float Param;
float4 PixelShaderFunction(float4 position : SV_POSITION, float4 color : COLOR, float2 texCoords : TEXCOORD) : COLOR
{
// return color here
}
technique Technique1
{
pass Pass1
{
// TODO: set renderstates here.
//VertexShader = compile vs_4_0_level_9_1 VertexShaderFunction();
PixelShader = compile ps_4_0_level_9_3 PixelShaderFunction();
}
}