how can i blend results of several passes in a fragment program?

i’m redrawing the geometry for each light oon the scene and i’m using fragment programs to do the lighting, so my doubt is how can i blend the results from the several passes?

Originally posted by jcabeleira:
i’m redrawing the geometry for each light oon the scene and i’m using fragment programs to do the lighting, so my doubt is how can i blend the results from the several passes?

Render the scene to one texure, then use the result texture in the next pass with fragment program.

Are there another way ?

isn’t a better way of doing the multipass blending than rendering the scene to a texture?

Usualy the scene lighting is the sum of all existing lights… You can use blending. Look into glBlendFunc. glBlendFunc(GL_ONE, GL_ONE) is what you look for.

Note that blending doesn’t work for floating-point render targets, only for good-old 8-bit-component RGB(A) buffers.

Using a texture should work well if you want to use floating point buffers (for HDR or whatnot).

Use the accumulation buffer if you have it. Same as the soft shadows demo.

i’ve copied the contents of the frame buffer for each pass to a different texture and additively blend them, and it looks fine!

for now i’m using glCopyCexImage2D but if i want to use render to texture i will have to create a pbuffer to render each pass to, right?

…if i want to use render to texture i will have to create a pbuffer to render each pass to, right?

Right, you will need a different pbuffer for each pass.