I’m trying to make a simple pixel shader in Monogame by creating a .fx file and importing it with the Content Pipeline tool. However, I’m using a Mac M1 and when I try to compile I get a build error from the Content.mgcb file. When I remove the .fx import it works fine, so that is definitely the cause.
Is it currently possible to use .fx files on Mac M1 machines? Are there any alternative workflows to using pixel shaders on my machine? Any help would be appreciated!
I’m not sure if mgfxc can be used on a Mac, because the documentation says it is for DirectX which will not work on any Mac. Macs use OpenGL.
I had trouble with fx files on a 3-D project I was working on. I could only get them to build correctly on Monogame 3.6 but not Monogame 3.8 The problem occurred for me on both an M-1 Mac and a Windows 11 box. Downgrading to Monogame 3.6 was the only way I could get fx files to work.
Yes I have installed Wine as described in the docs. I tried repeating the steps just now and I still get the same problems.
If it’s helpful, when I just try to compile the project with a .fx file in my Content.mgcb, I get an error when this part of MonoGame.Content.Builder.Tasks.targets is run:
<!-- Execute MGCB from the project directory so we use the correct manifest. -->
<Exec
Condition="'%(ContentReference.FullPath)' != ''"
Command="$(DotnetCommand) $(MGCBCommand) $(MonoGameMGCBAdditionalArguments) /@:"%(ContentReference.FullPath)" /platform:$(MonoGamePlatform) /outputDir:"%(ContentReference.ContentOutputDir)" /intermediateDir:"%(ContentReference.ContentIntermediateOutputDir)" /workingDir:"%(ContentReference.FullDir)""
WorkingDirectory="$(MSBuildProjectDirectory)" />
This is the .fx file I am trying to use. It is just a copy/pasted template right now so idk if there are any errors in it that would be interrupting compilation.
Once I have installed Wine that way and created the prefix, should shader compilation work automatically or is there a specific way I am supposed to use it to get it to run DirectX?
I actually solved it just after typing my reply! The solution is quite simple, the wineprefix script in the documentation is wrong and installs a x86 dotnet. Here is how to get it working:
delete the .winemonogame folder in your home directory
run the script from the documentation again, but replace master with develop
Oh wow, thanks for replying to this thread! I had given up solving this and was going to use a separate Windows Machine to handle compilation but that simple typo fix worked.
To summarize for anyone with this problem:
The default effect compiler via the content tool doesn’t work on Mac
Instead install Wine for use with MonoGame as described in the docs here, but…
For the wine install step, replace “master” with “develop” to get the correct script
Then, you can use MGFXC to compile effects directly as described in the docs here
If anyone reading this has access to the docs or could inform me how to update them it would be nice to see the MacOS set up page updated to reflect the new file structure.
You need to make a pull request for documentation changes, just like you would do for code changes.
You can do that right from that page. Just click the edit icon, make your changes, then click on the propose changes button.