【发布时间】:2017-05-29 08:55:34
【问题描述】:
我正在尝试在 Monogame 中实现一个 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 实现如下所示:
在加载内容中:
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 更改为 Opaque 会给我一个黑色的 Rectangle 纹理应该在的位置。我还尝试更改为其他 Sortmodes 和 BlendStates,但没有成功。我似乎无法找到问题。 任何有助于解决问题或减少我因此而产生的自我仇恨的答案都非常感谢!
编辑:资源绑定(注册)是否在整个着色器模型版本中发生了变化?! 有人请帮忙!
【问题讨论】: