Post Processing with XNA

Started by
2 comments, last by kriswithak 16 years, 2 months ago
So I've been hacking away at this problem for a good amount of time now, so I figured I'd ask before I go insane. I already looked at a bunch of articles and examples of adding post processing to my game, and I've successfully done 2 effects. However, this last effect I want to add is the Bloom PostProcess (Glow/Blur) one. I've already successfully brought it in to my game and seen it work. But the problem is in applying it to only a few textures. The way it is in the example, the effect is applied to the whole texture. I've tried using various combinations of rendertargets and spritebatches. But I still haven't gotten it to work properly. Any advice on what to do? Any examples out there that attempt to do what I'm doing? Cause all I seem to find are effects applied to whole scenes. Not specific parts. Thanks in advance.
Advertisement
There are a few ways to go about this. The two main options I can come up with off the top of my head are:

-Only render the elements you want to glow into the source texture you use as the source for your bloom effect. This means that you will have to render the bloom'ed elements twice, and you will have to maintain two separate render targets (although one of them can be your back-buffer).

-Store the bloom intensity in the alpha channel, and use that in your threshold pass to determine what needs to be bloomed. Downside is you lose the alpha channel of your render target, but this can be worked around...

EDIT: Here's a paper from Nvidia describing how to achieve this effect in OpenGL.
Quote:Original post by MJP
-Only render the elements you want to glow into the source texture you use as the source for your bloom effect. This means that you will have to render the bloom'ed elements twice, and you will have to maintain two separate render targets (although one of them can be your back-buffer).

You'll still need to render non-blooming elements into the bloom render target, but tinted solid black. This means that bloom will be correctly reduced/obscured by non-blooming objects (like a pillar in the foreground).
Do you think you could go a bit more in depth? Possibly with some examples. I took a look at the Nvidia doc and your post helped with the theory behind it, but I can't see how it would be put into practice. I mean, with what I've gathered so far, I would:
Start sprite batch.
set render target
draw things that I want to glow
resolve render target
draw other objects
draw glow
?

Thanks again.

EDIT:
This is the example I'm trying to implement:
http://creators.xna.com/Headlines/developmentaspx/archive/2007/01/01/Bloom-Postprocess-Sample.aspx

EDIT2:
So I think I've realized what my problem is. HLSL's are normally used when the scene is done rendering and you want to apply an effect to the whole scene. So would there be another way to go about this that doesn't use HLSL? And also that wouldn't slow the game down terribly. The game is 2D, if that helps at all.

[Edited by - kriswithak on February 18, 2008 4:56:41 PM]

This topic is closed to new replies.

Advertisement