0
我想在Monogame中实现PixelShader。MonoGame 2D PixelShader无法正常工作
着色器(现在)应该只需要一个纹理并将其恢复为未处理状态。
sampler MyTex : register(s0);
float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0
{
float4 Color = tex2D(MyTex, coords);
return Color;
}
technique tech
{
pass Pass1
{
PixelShader = compile ps_4_0_level_9_1 PixelShaderFunction();
}
}
我Monogame实现看起来是这样的:在
LoadContent:
spriteBatch = new SpriteBatch(GraphicsDevice);
texture = Content.Load<Texture2D>("surge");
GraphicsDevice.Textures[0] = texture;
effect = Content.Load<Effect>("sha");
,并在绘制方法:
GraphicsDevice.Clear(Color.Aquamarine);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend,null, null, null, effect, null);
spriteBatch.Draw(texture, new Vector2(150, 150), Color.White);
spriteBatch.End();
但是这说明不了什么。将BlendState更改为“不透明”会给我一个纹理应该是的黑色Rectangle。我也尝试改变其他Sortmodes和BlendStates没有成功。我似乎无法找到问题。 任何有助于解决问题的答案或正在减少我因为这个而产生的自我仇恨是非常感谢!
编辑:资源绑定(注册)在整个着色器模型版本中更改的问题?! 有人请帮忙!
谢谢您的回答,但与shaderfile我甚至不能编译。 MSBuild \ MonoGame \ v3.0 \ MonoGame.Content.Builder.targets(90,5):错误MSB3073:[..]以代码1结束 – Steffen