Issues compiling fx shader to MGFX

I’ve been trying to port Catalinzima’s 2D lighting example over to MonoGame to try and get some basic understanding around it and adapt it for use in my engine. I’ve been trying to convert the two .fx files provided with it to MonoGame compatable .mgfxo files. The first file ran through the converter and compiles successfully. However, the second file ran into issues converting; cmd Dump:

C:\Program Files (x86)\MSBuild\MonoGame\v3.0>2MGFX.exe resolveShadowsEffect.fx /DEBUG
C:\\Program Files (x86)\\MSBuild\\MonoGame\\v3.0\\resolveShadowsEffect.fx(213,8): error X5608: Compiled shader code uses too many arithmetic instruction slots (85). Max. allowed by the target (ps_2_0) is 64. (1,1): error X5609: Compiled shader code uses too many instruction slots (99). Max. allowed by the target (ps_2_0) is 96.

Failed to compile the input file 'resolveShadowsEffect.fx'!

So i thought fine, ill just change the PixelShader model to ps_3_0. Now this converts fine, but fails to compile in visual studio with the following errors:

A namespace cannot directly contain members such as fields or methods (1, 1)


Unexpected character ''	(1, 5)

In the visual studio error message this character shows as ‘|’ but its not the same when i paste it out.

I’ve tried comparing the first lines of the files, but have not been able to notice any differences.

I’m pretty new to using shaders, so i haven’t been able to debug whats going on effectively. Any ideas?

You can find the original shader files and compiled versions here:

Sorry… didn’t see this post.

I tried building the effects using the latest version of 2MGFX and they compile fine.

You may need to try one of our development installers which has the most current version of MonoGame including the latest tools.