I’m trying shaders for the first time in MonoGame. My only previous experience was with a couple of shaders I dabbled with in XNA, so I don’t really know what I was doing.
Using a recent binary install of MonoGame I have used the Pipeline tool to successfully build textures and music. I added a Shader .fx file that I knew worked in XNA to the project, set the Importer to “Effect Importer - MonoGame” and the Processor to “Effect - MonoGame”. When I first built the pipeline complained that it could not find D3DCompiler_43.dll - which as far as I can tell does not come with the MonoGame installer or the git repository. I did manage to find a copy of this DLL of unknown heritage lurking in a project sopmeone else had built which I must have doewnloaded sometime. I copied this to “C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools” and now when I try to build my content project I get:
Content/Shaders/FadeToGrey.fx: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Does this mean it’s working but MonoGame doesn’t like the format of my Shader? This shader worked in XNA:
// TODO: add effect parameters here.
sampler screen : register(s0);
texture source;
sampler map = sampler_state
{
Texture = <source>;
};
float greyness = 0;
struct VertexShaderOutput
{
float2 TexCoord : TEXCOORD0;
};
float4 FadeToGreyPixelShader(VertexShaderOutput input) : COLOR0
{
// TODO: add your pixel shader code here.
float4 col = tex2D(map,input.TexCoord);
float intensity = col.r/3 + col.g/3 + col.b/3;
return float4(greyness*intensity+((1-greyness) * col.r), greyness*intensity+((1-greyness)*col.g), greyness*intensity+((1-greyness)*col.b), col.a);
}
technique FadeToGreyTechnique
{
pass Pass1
{
PixelShader = compile ps_2_0 FadeToGreyPixelShader();
}
}
I have no idea what I’ve done wrong or how to fix it. Can you help?