PDA

View Full Version : floating point blending woes



brinck
02-21-2005, 03:53 AM
Hi,

much like the poster in the thread:

http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=3;t=012860

I want to render a particle cloud to a fp texture. I want to use multiplicative blending and the only way to make this work that I can see is:

- Create two floating point buffers
- Set one as render target and use the other one as a texture
- Render the particles one at a time as a fullscreen quad with clamped texture coordinates and multiply with the fp texture in a fragment program
- Flip the fp buffers and render the next particle

This will of course be horribly slow, is there another way?

/A.B.

brinck
02-21-2005, 04:08 AM
Ok, answering my own post. It just hit me that since the blending is order independent one doesn't have to do a fullscreen pass for each particle, the following should work just as well:

- Create two floating point buffers
- Set one as render target and use the other one as a texture
- Render the particles one at a time while multiplying with the fp buffer that is bound as a texture.
- Flip the fp buffers and render the next particle
- Bind both of the fp buffers as textures and multiply them together into a third buffer.

This will of course also be very slow since we're rendering the particles on at a time and changing render target in between.

/A.B.

brinck
02-21-2005, 04:11 AM
Hehe, even more comments on my own post. This won't work, I was writing my post before I hade finished thinking about it.

/A.B.

cass
02-21-2005, 04:23 AM
If fp16 blending is insufficient, then I would suggest splitting the scene up into slabs.

Each slab would become an fp16 texture with few enough blended elements for fp16 to be satisfactory.
You could accumulate the fp16 textures into an fp32 final at the end.

If fp16 is fundamentally unacceptable, then there's probably not a great gpu-based solution today.

brinck
02-21-2005, 04:24 AM
Of course, one can as the original poster suggested blit the result back to the main buffer after each render call, at the cost of twice the number of render target changes.

/A.B.

brinck
02-21-2005, 04:32 AM
Cass, is blending supported for 16-bit floating point textures? I didn't find anything in:

http://oss.sgi.com/projects/ogl-sample/registry/NV/float_buffer.txt

that suggested that it is.

/A.B.

Relic
02-21-2005, 04:53 AM
I think this is what you're looking for:
"16-bit Floating Point Blending and Filtering" on
http://download.developer.nvidia.com/developer/SDK/Individual_Samples/samples.html

cass
02-21-2005, 05:29 PM
Hi Andreas,

As Relic also pointed out, fp16 framebuffers support blending and fp16 texture support filtering.

I would definitely encourage trying that over doing a bunch of buffer changes and blits.

Thanks -
Cass