2011-01-05 39 views
0

在XNA 4.0中,設置「第二遍」着色器的正確方法是:如何獲取已渲染的幀,然後通過着色器程序運行整個渲染的屏幕?在XNA中運行第二遍渲染器的正確方法是什麼?

是否可以運行第三遍?

+0

您是否在討論在着色器中進行第二次傳遞? – 2011-01-05 08:40:28

+0

以下是您和您的問題的讀者可能會感興趣的相關文章:http://blogs.msdn.com/b/shawnhar/archive/2009/08/17/combining-shaders.aspx – 2011-01-05 12:06:55

回答

1

是的,這是可能的。您需要在RenderTarget2D上渲染場景,然後使用像素着色器在設備上渲染紋理。

RenderTarget2D target; // needs to instanciate in LoadContent(); 
Effect myEffect; // this one too. 
Draw(GameTime gametime) 
{ 
    GraphicsDevice.SetRenderTarget(target); 
    RenderScene(); 
    GraphicsDevice.SetRenderTarget(null); 

    spriteBatch.Begin(); 
    myEffect.CurrentTechnique.Passes[0].Apply(); 

    spriteBatch.Draw(.... , target, ...); 
    spriteBatch.End(); 
}