I'm currently following this tutorial but using MonoGame :
http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series1/Terrain_from_file.php
As said in the tutorial, my main goal is to render a terrain from an image file.
There is a .fx provided with the tutorial which I included in my project.
I had some issues using MonoGame to load the bmp file for example and now I managed to load it. The problem comes now from the fx file. MonoDevelop tells this : The MGX File is Corrupt !
Here is the original code from the writer of the article :
effect = Content.Load<Effect> ("effects");
And here is how I used it with MonoGame :
effect = Content.Load<Effect> ("effects.fx");
I am really lost about the usage of the effects file in MonoGame. Is there any good tutorial about this ? Anyway I'm really lost with MonoGame. How come there is no clear tutorials for MonoGame has it is widely used ?
I've been trying to follow Riemers tutorial myself, like you, I struggled with the effects.
I had to make a couple changes to the original effects file before I successfully managed to compile and use it without any exceptions.
Renamed the following:
Once these changes were made I used the compile tool like following:
Once compiled I moved the mgfxo file into my contents folder and assigned following parameters:
It took me a couple of attempts until I managed to use the shader without MonoGame throwing any exceptions at me.
You need to convert your shader .fx to appropriate file format for monogame using 2MGFX tool. You can find the tool inside installed monogame directory
C:\Program Files (x86)\MSBuild\MonoGame\v3.0
How to use:
2MGFX.exe effects.fx effects.mgfxo pause
Note that the shader file, .bat file and 2MGFX.exe must be in same directory.
Here is how to use compiled .mgfxo file as effect:
If you have problems converting a shader .fx to .mgfxo please leave comments.
Using the 2MGFX tool is optional, you can either use the tool or the Content pipeline, personally I prefer the Content pipeline because it will automatically process the shader file everytime I (re)build the Content project.
How to do this?
And use the shader like so:
or if you have folders in your content project: