【发布时间】:2014-04-09 05:51:21
【问题描述】:
我在 winrt 中使用 sharpdx 时遇到半透明问题。 首先,我的代码:
在 Mainpage.xaml 中,我添加了一个如下所示的 swapchainPanel:
<Grid>
<SwapChainPanel x:Name="Panel" />
</Grid>
// There is nothing else...
我使用与来自 github 的示例相同的类来渲染 3D 模型:
// Initialisation part
graphicsDeviceManager = new GraphicsDeviceManager(this);
graphicsDeviceManager.PreferredGraphicsProfile = new FeatureLevel[] { FeatureLevel.Level_11_0, };
graphicsDeviceManager.DepthBufferShaderResource = true;
还在同一个类中,加载内容时:
models = new List<Model>();
foreach (var modelName in new[] {"dude"})
{
model = Content.Load<Model>(modelName);
BasicEffect.EnableDefaultLighting(model, true);
models.Add(model);
}
model = models[0];
// Instantiate a SpriteBatch
spriteBatch = ToDisposeContent(new SpriteBatch(GraphicsDevice));
base.LoadContent();
最后,绘制部分:
// Clears the screen with the Color.CornflowerBlue
GraphicsDevice.Clear(Color.CornflowerBlue);
model.Draw(GraphicsDevice, world, view, projection);
base.Draw(gameTime);
一切都很好,但这是我为纹理模型得到的(注意到屏幕截图上的半透明有点棘手......)
这是我使用非纹理模型所拥有的...
我认为它来自 Alpha 模式下的渲染。我试图设置 BlendState 但我得到了一些例外,因为我没有使用正确的参数。
【问题讨论】:
-
看起来像深度模板缓冲区问题,因为 ModelRendering 示例正在工作,您应该从它重新开始并逐步检查您的更改破坏了什么
标签: c# windows-runtime sharpdx