【发布时间】:2013-08-10 00:18:23
【问题描述】:
我一直在尝试对我的 XNA 项目应用去饱和度和白噪声效果,我已经成功了,但现在我遇到了绘制顺序的一些问题。
在下面的代码中,注释掉的行是导致问题的原因。如果它们被注释,则绘制顺序问题已修复,但屏幕不会去饱和。取消注释时,屏幕会按照我的意愿去饱和,但会出现绘制顺序问题。
//GraphicsDevice.SetRenderTarget(scaleupTarget);
GraphicsDevice.Clear(Color.SeaGreen);
DrawModel(building_a_mdl, (Matrix.Identity * Matrix.CreateTranslation(100, -14, -100)), building_a_tex);
/*GraphicsDevice.SetRenderTarget(null);
scaleupEffect.Parameters["RandomOffset"].SetValue((float)rng.NextDouble());
GraphicsDevice.Textures[1] = noiseTexture;
spriteBatch.Begin(
SpriteSortMode.Texture,
BlendState.AlphaBlend,
SamplerState.PointClamp,
null,
null,
scaleupEffect);
spriteBatch.Draw(scaleupTarget, Vector2.Zero, null, Color.White, 0.0f, Vector2.Zero, upScaleAmount, SpriteEffects.None, 0.0f);
spriteBatch.End();*/
【问题讨论】:
-
究竟是什么画不正确?您是否尝试在调用 SpriteBatch.Begin() 时更改 BlendState?
-
@davidsbro 如果您仔细观察黑白图像(很难看到),但您可以看到建筑物另一侧的窗户正在通过它进行渲染——一组横穿模型。我已经更改了 BlendState、SpriteSortMode 和 SamplerState,但都没有运气。
-
@JamesMonger 在绘制模型之前是否更改了 DepthStencialState 和 RasterizerState?
-
@Blau 我更改了 DepthStencilState 但没有运气 - 我没有更改 RasterizerState。
-
为什么不在绘制 3D 模型之前尝试设置 'GraphicsDevice.RenderState.DepthBufferEnable = true' 行。我只记得我遇到了与您相同的问题,并且在每次抽签解决问题之前将其设置为 true。