Loading shaders in WindowsGL and Android


I’m using Xamarin to build a game that runs on Android and WindowsGL using MonoGame 3.4. So far everything runs great on both platforms, but I’m having troubles loading shaders on either clients. I used the basic shader from here https://github.com/mono/MonoGame/wiki/Effects-And-Shaders and ran it through the content builder (also latest version freshly installed) to get the xnb to add to my projects. The file is then found but can’t be loaded by the ContentManager due to a “The MGFX effect was built for a different platform!” exception.

I understand that the shader is written in HLSL which is used in DirectX and im trying to run it on OpenGL clients, but I read that MonoGame compiles the code internally to run on both and then selects the right one depending on the graphics API used.

Help would be much appreciated!

  • Oblotzky

PS: Eventually I just want to create a couple pixel shaders for sprite rendering and post-processing effects.

I found the solution now after googling my ass off, there are global settings for the content project as you can see in the second image here http://kgiannakakis.github.io/MonoGameEffects/. WindowsGL compiled content now also runs on Android, but I’ll compile it for each platform seperately with the correct setting just in case. Also needed to change the ps_5_0 to ps_2_0 in the shader (must be 3 or lower). Just never saw those settings as I never had the root node selected I guess.