Front to Back vs Back to Front Compositing

I am writing a volume renderer with volumetric shadows using a 3d texture and slicing planes. Depending on the light position, I either have to composite the slices from front to back or back to front. For back to front compositing I use glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA) and for front to back compositing I use glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE). Then in my fragment shader I multipy the fragment colors by the alpha value for both types of compositing. The results are very close, but the front to back compositing image is slightly brighter (especially noticable on the edges). I have worked out several examples by hand using these two algorithms and the results always match. The only thing I can think of is perhaps this is caused by numerical errors (roundoffs and such). If anyone has any other ideas please share. I will try to post some screenshots so you can see the difference (while slight it seems like a lot for just numerical errors).

Ok here are some screenshots. First we have the back to front compositing:

Now front to back:

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)

=> you add the current slice, but blend what is already there. This accumulates to darker edges where the alpha values are < 1.0.

glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE)

=> the destination is only added to. Although you might loose some edge brightness per layer, in the end it’s all being added up, causing brighter transparencies.

Originally posted by def:
[b]

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)

=> you add the current slice, but blend what is already there. This accumulates to darker edges where the alpha values are < 1.0.[/b]
I’m pretty sure my back to front compositing is correct. Since I multiply each fragment’s color by its alpha value in the fragment shader, the above is equivalent to glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) (if I didn’t do the multiplication in the fragment shader). If I’m not mistaken this is the standard equation for back to front compositing.

Originally posted by def:[b]

glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE)

=> the destination is only added to. Although you might loose some edge brightness per layer, in the end it’s all being added up, causing brighter transparencies.[/b]
True, I am not weighting the destination alpha. However it has already been weighted when the previous slice was computed (before being stored in the frame buffer). While it doesn’t seem intuitive that these two algorithms would produce the same result, I have worked out several examples by hand and the results are always the exact same.

It all depends on how your slices color and alpha looks like. If the color image is a greyscale image on a black background it is already multiplied by some alpha.
If your slices color and alpha looks the same use a solid white color and do the standard glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) and you should not loose any brightness.

I don’t know if that is the case with your slices, but it’s a common problem found in 2d compositing.

The slices don’t really have their own color and alpha per se. My 3d texture just has one value, the data values from the volumetric data set. Then in my fragment shader I scale this data value to assign a brightness (the RGB values for the slice) and I do the same for the alpha (but scaled with a different value).