PDA

View Full Version : Correct blending without stencil buffer use solution



GONS
05-20-2003, 06:32 AM
Hi people!

I have developed a configurable particle system, but I hit me with the problem who draw textures of particles with one mode blend and add with the back scene with other blend.One solution is use the stencil buffer, but it's no good idea, it's not eficient in this case. I belive that exist other more esay and fast way.

The basic problem is opengl draw back to front, thus the framebuffer is now full of back texture info scene, and when add the sume of textures of particle the result is
ADD operation, and this is not correct.
Imagine that my texture of particle have a red RGB color like (0.1 0 0), thus the add with other particles, the sume will be (1 0 0), but if I have a back texture with white RGB color (1,1,1) this wouldn't have repercussion in the final color with first RGB color .But with the typical blend parameters like glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); can do this. The result is (1.0,1.0,1.0) the ADD.

Anybody know a good way to do it correct.

Thanks;P

Gons.