Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mono 在.fx效果文件中加载单游戏_Mono_Monogame - Fatal编程技术网

Mono 在.fx效果文件中加载单游戏

Mono 在.fx效果文件中加载单游戏,mono,monogame,Mono,Monogame,目前,我正在尝试将以下教程中的.fx文件加载到monogame中 FX文件如下所示: sampler s0; texture lightMask; sampler lightSampler = sampler_state{Texture = lightMask;}; float4 PixelShaderLight(float2 coords: TEXCOORD0) : COLOR0 { float4 color = tex2D(s0, coords);

目前,我正在尝试将以下教程中的.fx文件加载到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,需要重新构建


我已经浏览过网络,我正在努力了解为什么会发生这种情况。任何帮助都将不胜感激

所以问题是HLSL文件中的一行代码

sampler lightSampler = sampler_state{Texture = lightMask;}; 
应该是

 sampler lightSampler = sampler_state{Texture = <lightMask>;}; 
sampler lightSampler=sampler_state{Texture=;};
有趣的是,它是在没有这个的情况下编译的,但是monogame不喜欢它