Monogame 3.8.1 Shader Compiling on Linux

Hello all,

Is it possible to compile a HLSL .fx file in the MGCB on linux without requiring Wine configuration? Or if there is Wine configuration required, are there any easy steps that I can follow to get a shader into my project?

I’ve recently switched across my machine to Linux Mint and I’m using vscode with .NET9. It’s very difficult to get a straight working answer on this topic. Would I have to switch to .NET8 where I’ve read it’s more stable?

Any help is appreciated.

Not without Wine, unfortunately. I haven’t been able to get it working with Wine either (also on Linux Mint, though I’m using dotnet 10. I hadn’t considered that that might be causing the issues).

That said, when MonoGame 3.8.5 releases, it will include a new Vulkan backend that will support native shader compilation for both Linux and Mac, so I’ve been holding out for that.

Thanks very much for your response @greenstack

I’ve managed to figure it out and have gotten a OpenGL shader effect working in my game.

It’s quite complicated to get everything working, but a key thing was me going back to Monogame University tutorials about 2D shaders where Simon quite clearly mentioned that you have to get the syntax of the shader exactly correct.

I ended up doing a fresh install of linux to try it again and installed .NET 10 targeting net9.0 and it works too.

It actually is possible using ShadowDusk: ShadowDusk | ShadowDusk — Cross-Platform MonoGame Shader Compiler

It’s what is used on xnafiddle where you can export projects locally, linking shadowdusk, and compile/run them just fine on Linux. XnaFiddle

Try it out!

For anyone else having trouble, I recently (yesterday and today) got this working on Fedora 43 on two devices, my experience is noted in issue #8059 on GitHub. (Apparently forum rules prohibit me from posting a link to it…)

It seems like the biggest thing that helped me on both was installing both wine and wine64 and then running winecfg afterwards. Also, make sure the profile that your shell uses is actually updated, by default the install script updates .profile and .zprofile, but my install uses .bash_profile. Then, because Rider didn’t like picking up the .bash_profile updates, I did a reboot.

Note: this was on 3.8.5, but I have a suspicion it should be successful on 3.8.1 as well.