1 / 12

XBLIG-UK 2011

XBLIG-UK 2011. Post Processing in XNA 4.0 By Charles Humphrey. 2nd March 2011. Wikipedia says:-

merlin
Télécharger la présentation

XBLIG-UK 2011

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XBLIG-UK 2011 Post Processing in XNA 4.0 By Charles Humphrey 2nd March 2011

  2. Wikipedia says:- “Post-processing is commonly used in 3D rendering, especially for video games. Instead of rendering 3D objects directly to the display, the scene is first rendered to a buffer in the memory of the video card. Pixel shaders are then used to apply post-processing filters to the image buffer before displaying it to the screen. Post-processing allows effects to be used that require awareness of the entire image (since normally each 3D object is rendered in isolation).” What is Post Processing?

  3. Post Processing Pipeline

  4. Holds a list of BasePostProcessingEffect • Draw method • Receives the rendered scene and depth map as textures. • Loops through each BasePostProcessingEffect • Call their Draw methods. • Current scene is up dated after each BasePostProcessingEffect.Draw call to be passed onto next BasePostProcessingEffect • Renders the final scene texture PostProcessingManager

  5. Holds a list of BasePostProcess • Draw Method • Stores a copy of the original scene. • Loop through each BasePostProcess. • Set Half Pixel value. • Pass original scene texture (not all need it) • Set the BasePostProcess render target • Set the BasePostProcess back buffer (current scene) • Set the BasePostProcess depth buffer • Call the BasePostProcess Draw method • Resolve the BasePostProcess render target • Record the last scene rendered texture (used for next BasePostProcess’s back buffer) BasePostProcessingEffect

  6. Holds an Effect for the required pixel shader • Renders the scene texture and applies the pixel shader BasePostProcess

  7. Depth of Field • Poison Disc Blur • Depth of Field • Bloom • Bright Pass • Gaussian Blur • Vertical • Horizontal • Bloom • Haze • Bump map Distort • Radial Blur • Radial Blur • Ripple • Ripple • Fog • Fog • Sun • Sun Post Process Samples

  8. Write your pixel shader • Derive from BasePostProcess • public class Bloom : BasePostProcess • Override the Draw call public override void Draw(GameTimegameTime) { if (effect == null) { effect = Game.Content.Load<Effect>("Shaders/PostProcessing/Bloom"); effect.CurrentTechnique = effect.Techniques["BloomComposite"]; } effect.Parameters["SceneTex"].SetValue(orgBuffer); effect.Parameters["BloomIntensity"].SetValue(BloomIntensity); effect.Parameters["BloomSaturation"].SetValue(BloomSaturation); effect.Parameters["BaseIntensity"].SetValue(BaseIntensity); effect.Parameters["BaseSaturation"].SetValue(BaseSaturation); // Set Params. base.Draw(gameTime); } Creating a Post Process

  9. Derive from BasePostProcessingEffect • public class BloomEffect : BasePostProcessingEffect • Create the Post Process instances you need bp = new BrightPass(game, threshold); gbv = new GaussBlurV(game, blurAmount); gbh = new GaussBlurH(game, blurAmount); b = new Bloom(game, intensity, saturation, baseIntensity, baseSatration); • Add them to your list of BasePostProcess’s AddPostProcess(bp); AddPostProcess(gbv); AddPostProcess(gbh); AddPostProcess(b); Creating a Post Process Effect

  10. Create and instance of the Post Processing Manager • ppManager = new PostProcessingManager(this); • Create instance of your new effect • bloom = new BloomEffect(this, 1.25f, 1f, 1f, 1f, .25f, 4f); • Add to the Post Processing Manager • ppManager.AddEffect(bloom); Use the new Post Process Effect

  11. Questions?

  12. Kyle Hayward aka Graphics Runner Blog http://graphicsrunner.blogspot.com Post Processing Sample http://graphicsrunner.blogspot.com/2008/06/post-process-framework-sample.html Inspiration from…

More Related