Monogame和.fx文件? [英] Monogame and .fx files?
问题描述
我目前正在学习本教程,但使用MonoGame:
http://www.riemers.net/eng/Tutorials/XNA /Csharp/Series1/Terrain_from_file.php
如本教程所述,我的主要目标是从图像文件渲染地形.
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.
该教程提供了一个.fx,我将其包含在项目中.
There is a .fx provided with the tutorial which I included in my project.
例如,在使用MonoGame加载bmp文件时遇到了一些问题,现在我设法加载了它.现在问题出在fx文件中. MonoDevelop告诉了这一点:The MGX File is Corrupt !
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 !
这是文章作者的原始代码:
effect = Content.Load<Effect> ("effects");
Here is the original code from the writer of the article :
effect = Content.Load<Effect> ("effects");
这是我与MonoGame结合使用的方式:
effect = Content.Load<Effect> ("effects.fx");
And here is how I used it with MonoGame :
effect = Content.Load<Effect> ("effects.fx");
我真的对MonoGame中的效果文件的使用一无所知.关于这个有什么好的教程吗?无论如何,我真的迷上了MonoGame.为什么没有被广泛使用的MonoGame清晰教程?
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:
- vs_2_0至 vs_4_0
- ps_2_0至 ps_4_0
- POSITION到 SV_POSITION
- vs_2_0 to vs_4_0
- ps_2_0 to ps_4_0
- POSITION to SV_POSITION
进行了这些更改后,我将使用如下所示的编译工具:
Once these changes were made I used the compile tool like following:
2MGFX.exe effects.fx effects.mgfxo/Profile:DirectX_11
编译后,我将mgfxo文件移到目录文件夹中并分配了以下参数:
Once compiled I moved the mgfxo file into my contents folder and assigned following parameters:
- 构建操作:嵌入式资源
- 复制到输出目录:始终复制
经过了几次尝试,直到我设法使用着色器,而MonoGame并没有向我抛出任何异常.
It took me a couple of attempts until I managed to use the shader without MonoGame throwing any exceptions at me.
byte[] bytes = File.ReadAllBytes("Content/effects.mgfxo");
effect = new Effect(GraphicsDevice, bytes);
这篇关于Monogame和.fx文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!