Basically, what I'm trying to do is apply a shader to my background image and only the background image. The problem is: the background is actually made up of tiles that are picked out of a list of images. The background code loads and draws the tiles according to a map (an int[,].) I've been reading up on using RenderTarget2d, but I haven't found anything that suggests I'd be able to use specific images (let alone images set up according to a map.) So here's my question: is there a way to render my backgrounds to a texture so I can apply a shader or is there another way for me to apply a shader that I might want to try?
You seem to have already figured out how to do this. Here's the process:
GraphicsDevice.SetRenderTarget(myRenderTarget); RenderMyBackground(); GraphicsDevice.SetRenderTarget(null); spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, myShaderEffect); spriteBatch.Draw(myRenderTarget, Vector2.Zero, Color.White); spriteBatch.End(); RenderEverythingElse();
You may want to have a look at the Bloom Postprocess sample. There's no reason you have to apply a post-process effect to your entire scene. You can apply it to just your background and then draw the rest of your scene over the top.