This is why we request a certain window size by setting Game.PreferredBackBufferWidth and Game.PreferredBackBufferHeight. Thus, when we render, we are drawing into a back buffer, and once that drawing is complete, we flip the buffers so that the one we just finished is what ends up being rendered on-screen, and we now can start drawing into the next back buffer. MonoGame uses the graphics hardware to render the scene, along with double buffering. By overriding this method, and adding your own rendering code, you fulfill the draw step of the game loop. If you think you've found a bug porting a shader, please let us know.The Game.Draw(Game.Update(GameTime gameTime) method is a another hook, this one for adding your game’s rendering code.The effect compiler is aggressive about removing unused parameters, be sure the parameters you are setting are actually used.
Either set the parameter from code or use a real constant like a #define.
These are some tips for writing or converting effects for use with MonoGame. Process your effect file with the MGFXC tool and load them yourself at runtime.Run the effect file through the MonoGame Effect content processor for loading via the ContentManager (Recommended).To use a custom effect with MonoGame you must do one of the following: 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. The source and pre-compiled versions of these effects can be found in the 'MonoGame.Framework\Platform\Graphics\Effect\Resources' folder. Under the hood these effects use the same system and tools as one would for a custom Effect. MonoGame has the following effects built-in and fully supported on current platforms: Easy to extend for future platforms and features.Be cross-platform and support multiple shader languages and bytecodes.Have a compiled and optimized binary format for runtime use.Have a textual format for ease of editing.Support a similar technique, passes, shaders structure as Microsoft FX files.MGFX is MonoGame's own "FX" runtime and tools which with the following core goals: 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. A core element of Microsoft XNA is the effect system which is used for all rendering.įor 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.