complex blending

Hi all,

First, a simple question : what is the more efficient between copying data from framebuffer to texture and from texture to texture ?

An other question :
I render a set of triangles. When one overlap another one, i must do some computation iteratively, like blending, but i can’t use it. So i do that in a fragment program. i render triangle per triangle. For each one i update a texture containing all my informations. This texture is used as an input in my fragment program, so i can’t write in it, so i write my new informations in the framebuffer. And after i need to copy the updated part of the framebuffer to my texture. This is very slow. So i’m searching for an other solution to do my computations.

here is what i do :
set the input texture of the fragment program
for each triangle {
render the triangle to the framebuffer (using the fragment program)
copy updated part of the framebuffer to the texture
}

Is there a well known solution to do that faster ?

(sorry for my bad english)
thx

Well, try to find another way…

If I understand you correctly, you have to perform some sort of custom blending where your blending function depends on color input and already rendered image. This is a bad idea :slight_smile:

You could optimise your technique if you sort your triangles(bzw, with BSF) z-wise and render a whole non-overlapping group each time.

To me it sounds like OP hasn’t seen COMBINE yet, a.k.a. multi-texturing. Chances are you can do at least 6 (six!) combinations for every textured pixel using this approach, and it won’t even require shaders!

If you (think you) really need readback FB pixels from every texturing stage, I think you need to explain it a bit more in detail (before I believe it).