Skip to content

Effects And Shaders

tomspilman edited this page May 19, 2012 · 26 revisions

Overview

A core element of Microsoft XNA is the effect system and the shaders it uses. 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 Suite.

MGFX

MGFX is MonoGame's own "FX" file format which has the following core goals:

  • Support a similar technique, passes, shaders structure as Microsoft FX files.
  • Have a textual format for ease of editing.
  • Have a compiled and optimized binary format for runtime use.
  • Be cross-platform and support multiple shader languages and bytecodes.
  • Easy to extend for future platforms and features.

2MGFX

NOTE: At this time 2MGFX only supports FX files as input as the textual format is not yet complete.

Stock Effects

The following stock effects in MonoGame and fully supported on all current platforms:

  • BasicEffect
  • AlphaTestEffect
  • DualTextureEffect
  • EnvironmentMapEffect
  • SkinnedEffect

Under the hood these effects use the same tools as one would for any 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 shaders 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 process your effect with the MGFX tool.

Roadmap

There is still work to be done for better support of custom effects and shaders in MonoGame:

  • Implement textual MGFX format for direct editing of effects.
  • Make MGEffectProcessor which can be used from the content pipeline.
  • Make automated tests for custom effects.
  • Support PlayStation Suite shaders in MGFX tools and formats.
  • Expose a API from MonoGame which can be used for low level access to shaders.
  • String table all strings stored in MGFX files to save more space.
  • Support pre-compiled GLSL assembly instead of GLSL code.

Clone this wiki locally