我有一些这样的代码:
GraphicsDevice.SetRenderTarget(0, myRenderTarget);
GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);
myEffect.Begin();
myEffectCurrentTechnique.Passes[0].Begin();
spriteBatch.Draw(aRegularTexture, Vector2.Zero, Color.White);
spriteBatch.End();
myEffect.CurrentTechnique.Passes[0].End();
myEffect.End();
GraphicsDevice.SetRenderTarget(0, backBuffer);
Texture2D bloomTexture = myRenderTarget.GetTexture();
...
GraphicsDevice.SetRenderTarget(0, myRenderTarget);
GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin();
spriteBatch.Draw(aRegularTexture, Vector2.Zero, Color.White);
spriteBatch.End();
GraphicsDevice.SetRenderTarget(0, backBuffer);
aRegularTexture = myRenderTarget.GetTexture();
//SHOULD be doing nothing, since I'm just rendering said texture into a render target and pulling it back out
(注意:这是精简到最小的复制代码,不是我实际使用的)
如果我在第二个代码块之前将 aRegularTexture 渲染到屏幕上,它看起来很好并且没有受到影响。但是如果我在第二个代码块之后渲染它,它就会被设置为 aModifiedTexture 的内容,即使我从来没有做任何会导致这种情况的事情。为什么?(使用 XNA 3.1)