在.fx效果文件中加载Monogame

时间:2016-01-17 11:53:48

标签: mono monogame

目前我正在尝试从以下教程加载到monogame .fx文件中 http://www.xnahub.com/simple-2d-lighting-system-in-c-and-monogame/

FX文件如下:

sampler s0;  

texture lightMask;  
sampler lightSampler = sampler_state{Texture = lightMask;};  

float4 PixelShaderLight(float2 coords: TEXCOORD0) : COLOR0  
{  
    float4 color = tex2D(s0, coords);  
    float4 lightColor = tex2D(lightSampler, coords);  
    return color * lightColor;  
}  


technique Technique1  
{  
    pass Pass1  
    {  
        PixelShader = compile ps_2_0 PixelShaderLight();  
    }  
}  

我已经使用2MFGX.exe工具将我的.fx文件转换为编译良好的mgfxo文件,但是当我尝试使用此代码将mfgxo文件加载到我的游戏中时:

        Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("Mist.Content.lighteffect.mgfxo");
        BinaryReader Reader = new BinaryReader(s);
        effect1 = new Effect(GraphicsDevice, Reader.ReadBytes((int)Reader.BaseStream.Length)); 

我收到以下错误:

此MGFX效果适用于较早版本的MonoGame,需要重建。

我已经浏览了网页,我正在试着理解为什么会发生这种情况。任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:1)

事实证明问题是HLSL文件中的一行代码。

sampler lightSampler = sampler_state{Texture = lightMask;}; 

应该是

 sampler lightSampler = sampler_state{Texture = <lightMask>;}; 

有趣的是它没有这个被编译,但是monogame不喜欢它。

相关问题