PDA

View Full Version : how can i blend results of several passes in a fragment program?



jcabeleira
02-15-2004, 12:43 AM
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?

foollove
02-15-2004, 12:52 AM
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 ?

jcabeleira
02-15-2004, 01:49 AM
isn't a better way of doing the multipass blending than rendering the scene to a texture?

Zengar
02-15-2004, 02:16 AM
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.

jwatte
02-15-2004, 03:17 PM
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).

chemdog
02-17-2004, 06:47 PM
Use the accumulation buffer if you have it. Same as the soft shadows demo.

jcabeleira
02-18-2004, 06:00 AM
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?

ZbuffeR
02-18-2004, 07:48 AM
....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.