PDA

View Full Version : Front-to-back blending not working



chracatoa
12-14-2005, 08:13 AM
I'm trying to do volume rendering and sometimes I traverse the data front-to-back and sometimes back-to-front. Back-to-front compositing works fine:

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

but when I try front-to-back using this:

glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE);

everything becomes white.

I have 8 alpha bit planes [I checked with glGetIntegerv(GL_ALPHA_BITS, &i)] and I'm using pbuffers (I don't know if it matters). I am clearing the image with glClearColor(0,0,0,0) (I've tried with 0,0,0,1 without success anyway).

Any ideas?

Edited: I said I was using the same compositing equation, but I copied and pasted the same API call by mistake. It is fixed now.

Klaus
12-14-2005, 10:40 AM
You must use destination alpha. Use:

glBlendFunc(GL_ONE_MINUS_DST_ALPHA,GL_ONE);

Klaus

Edit: You should also use pre-multiplied colors in your transfer function (RGB multiplied with ALPHA).

chracatoa
12-14-2005, 11:27 AM
oops, that is what I did

glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE);

I was reading your reply and thinking: "he's telling me to do what I already do!", lol.

I will try to multiply color with alpha. Thanks!