PDA

View Full Version : Selective additive blending?



GetLastError
08-27-2012, 08:13 AM
Hi all,

First post :)

How do you correctly render a particle effect, which have particles that are blended additively, onto an image background?

The particles are also blended additively to the background, how can avoid that? (i.e blend them additively to each other but not to the background as well)

Actually, I have additional constraints:

I'm working on a 2D game for mobile devices (OpenGL ES 2.0) that is rendered using 8 layers as follows:

1. Background #1 (parallax scrolling)
2. Background #2 (parallax scrolling)
3. Background #3 (parallax scrolling)
4. Particle Effects Layer #1
5. Game Objects
6. Particle Effects Layer #2
7. UI
8. Particle Effects Layer #3

If FBO is the only way to go to solve the blending problem, I'd have to create 8 textures that have the screen dimensions, and render each layer separately to the FBO. Then rendering the 8 textures to the window frame buffer which is too heavy on memory. I can alternatively use a single texture but that'll require 16 FBO switches...

Any tips?

ZbuffeR
08-27-2012, 10:48 AM
From your description, it seems you only need to use 1 FBO for each special effects layer. Then blend that non additively.
But why do you need to add-blend particles between themselves and not with the background ? Any real reason ?

GetLastError
08-27-2012, 02:17 PM
From your description, it seems you only need to use 1 FBO for each special effects layer. Then blend that non additively.
But why do you need to add-blend particles between themselves and not with the background ? Any real reason ?

1 FBO for each particle layer means 3 FBOs and 6 FBO switches... it seems like a big penalty (memory, performance) to do it for just a few particle effects, I hoped that there is some kind of other solution, what everybody do?

I attached an image that illustrates the problem.

http://i45.tinypic.com/9kt15x.png

michagl
09-10-2012, 02:13 PM
This sounds like a simple problem with many solutions that would not be intensive.

Maybe if you more precisely explained your situation (and problems) a best answer would be very easy to come by.

For instance. Do you want the effect on the right to look like the one on the left?

And can you just draw your 1, 2, 3, 4 (and so on) in that order (over one another) ?