Custom Effects

A core element of Microsoft XNA is the effect system which is used for all rendering.

For MonoGame we have the burden of supporting stock and custom effects for desktop GLSL, mobile GLSL, DirectX HLSL, and custom formats like that of the PlayStation Mobile. There currently is no effect system or shader language that supports all the platforms we require, forcing us to build a new custom effect system.

MGFX

MGFX is MonoGame's own "FX" runtime and tools which with the following core goals:

Stock Effects

MonoGame has the following effects built-in and fully supported on current platforms:

Under the hood these effects use the same system and tools as one would for a custom Effect. The source and pre-compiled versions of these effects can be found in the 'MonoGame.Framework\Graphics\Effect\Resources' folder.

If your game requires an extra little bit of performance you can easily hand edit the existing effects to remove unnecessary features or optimize for specific hardware and rebuild them with the MGFX tool.

Custom Effects

To use a custom effect with MonoGame you must do one of the following (not both):

Effect Writing Tips

These are some tips for writing or converting effects for use with MonoGame.

#if OPENGL
  #define VS_SHADERMODEL vs_3_0
  #define PS_SHADERMODEL ps_3_0
#else
  #define VS_SHADERMODEL vs_4_0_level_9_1
  #define PS_SHADERMODEL ps_4_0_level_9_1
#endif

technique
{
  pass
  {
      VertexShader = compile VS_SHADERMODEL MainVS();
      PixelShader = compile PS_SHADERMODEL MainPS();
  }
};

Custom symbols can be defined from the Pipeline Tool or via 2MGFX.