Hi there!
I was wondering if I could get a hand with an issue I get loading custom Effect files at runtime.
I have all of my effects in a Monogame Pipeline tool project :
And I’m not getting any warnings or errors when building; the build generates a series of .xnb files - one for each Effect.
However when I try and load one of the Effects at runtime
Content.Load( filePath )
An exception is generated, telling me that the MGFX file I’m trying to load is corrupt. Any Idea why this might be happening - this is the Effect I’m trying to load
// --------------- Globals -----------------
float4x4 World;
float4x4 View;
float4x4 Projection;
// --------------- Samplers ---------------
Texture2D ColourMap;
SamplerState colourMapSampler
{
Filter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
// --------------- Structures ---------------
struct VertexShaderInput
{
float2 myTexCoord : TEXCOORD0;
float4 myPosition : POSITION0;
float4 myColour : COLOR0;
};
struct VertexShaderOutput
{
float4 myPosition : POSITION0;
float2 myTexCoord : TEXCOORD0;
float4 myColour : COLOR0;
};
// --------------- Vertex Shader ---------------
VertexShaderOutput VS( VertexShaderInput input )
{
VertexShaderOutput output;
float4 worldPosition = mul(input.myPosition, World);
float4 viewPosition = mul(worldPosition, View);
output.myPosition = mul(viewPosition, Projection);
output.myTexCoord = input.myTexCoord;
output.myColour = input.myColour;
return output;
}
// --------------- Pixel Shader ---------------
float4 PS(VertexShaderOutput anInput) : COLOR0
{
float4 colour = ColourMap.Sample( colourMapSampler, anInput.myTexCoord );
// Discard pixels with an alpha of 0, as we don't want them to write to the stencil buffer
colour = saturate( colour * anInput.myColour );
if( colour.w == 0.0f )
{
discard;
}
return colour;
}
// ---------------- Techniques ----------------
technique Technique1
{
pass Pass1
{
VertexShader = compile vs_4_0 VS();
PixelShader = compile ps_4_0 PS();
}
}
Thanks for the help!