开发者

Implementing a PostProcessing manager

开发者 https://www.devze.com 2023-01-10 23:20 出处:网络
I have been thinking about how to implement a PostProcessing manager into my engine (Vanquish). I am struggling to get my head around how a Post Processing technique works. I have read and viewed the

I have been thinking about how to implement a PostProcessing manager into my engine (Vanquish).

I am struggling to get my head around how a Post Processing technique works. I have read and viewed the Post Processing sampl开发者_JS百科e on the creators.xna.com webiste, but this seems to re-render the model applying the Post Processing effect.

I can add this functionality for static models, but when it comes to redrawing the Skinned Models, I then get confused as they already have their own techniques to their effects.

Can someone help me straighten my thoughts by pointing me in the right direction?


Generally post-processing works over the entire screen. This is pretty simple, really.

What you do is set a render target on the device (I assume you can figure out how to create a render target from the sample):

GraphicsDevice.SetRenderTarget(renderTarget);

From this point onward everything you render will be rendered to that render target. When you're done you can set the device back to drawing to the back buffer:

GraphicsDevice.SetRenderTarget(null);

And finally you can draw using your render target as if it were a texture (this is new in XNA 4.0, in XNA 3.1 you had to call GetTexture on it).

So to making a post-processing effect:

  • Render your scene to a render target
  • Switch back to the back buffer
  • Render your render target full screen (using SpriteBatch will do) with a pixel shader that will apply your post-processing effect.

You sound like you want to do this per model? Which seems kind of strange but certianly possible. Simply ensure your render target has a transparent alpha channel to begin with, and then draw it with alpha blending.

Or do you not mean post-processing at all? Do you actually wish to change the pixel shader the model is drawn with, while keeping the skinned model vertex shader?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号