One of the things which I wanted to implement in the Vertices Engine were Crepuscular Rays, more commonly known as God Rays. These have become ubiquitous in games within the last 5 years. Some games get it right, and add it lightly in to add a sense of depth and atmosphere to a game. Others over do it and wash out the screen (Looking at you Dishonored).
The other post processing effect that’d been on my wishlist was Depth of Field.
It wasn’t too difficult to get them running individually on their own in little test projects, but integrating them into the engine was something I’d been putting off for a while.
After a weekend of tweaking, i managed to finally get them both integrated into the engine and working under XNA, but the true test of the simplicity of any code is being able to port it over to another platform.
Porting into Linux
MonoGame is great, but there’s a few nuances too porting shader code over well. One of the biggest is making sure global variables are initialised. In XNA if you have a *.fx file with a globalvariable such as:
float SpecularIntensity = 1
In MonoGame, you’ll need to re-initialise that value of of 1 in your *.cs file from C#.
part.Effect.Parameters[“SpecularIntensity“].SetValue(_specularIntensity);
This was a big head ache of chasing problems when I was porting over Bloom.
After a few tweaks in the *.fx files, they ported over too OpenGL without much more fuss than what I’d mentioned already. MonoGame has gotten to the level now where porting over is becoming easier and easier with each release.
Ported Depth of Field and Crepuscular Rays Post Process from #Windows into #Linux #MonoGame. It’s been a good day. pic.twitter.com/zPSOrP5eoA
— virte.c (@virte_c) March 27, 2016