50 Shaders of Grey

After about another half hour or so of trying everything, I finally got shaders working in my Linux-developed FNA project.  Here’s what I learned:

  1. MGCB doesn’t build shaders at all on Linux at the moment (System.NotImplementedException).
  2. 2MGFX only works when run on Windows at the moment.  So, you’ll at least need a Windows VM to do anything original with shaders in MonoGame/FNA Linux projects.
    1. UPDATE:  While 2MGFX doesn’t work when run directly via mono on Linux (because it needs to use some Windows DLLs that appear to need other Windows APIs), you can run it via Wine (i.e. “wine 2MGFX.exe jlblur.fx jlblur.mgfxo /Profile:OpenGL”).  I did this successfully with a 32-bit build of 2MGFX (see next item).
  3. The 2MGFX project assumes you’re building a 64-bit target.  You’ll have to update it if you’re running a 32-bit VM, as I am.  Also, you’ll need to replace libmojoshader_64.dll with the 32-bit version.  I believe you’ll also need to get the 32-bit d3dcompiler_43.dll and put it in the 2MGFX.exe’s directory.
  4. The signature for the pixel shader should have all the parameters declared like so:
float4 PixelShaderFunction (float4 position : POSITION, float4 color : COLOR0, float2 coords : TEXCOORD0) : COLOR0

There’s more info on the MonoGame Documentation Custom Effects page, and some Hints, Tips, and Gotchas here.