• Welcome to Dark Bit Factory & Gravity.
 

opengl blending

Started by Stonemonkey, December 06, 2006

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Stonemonkey

I'm trying to do something with blending but can't get it working. I'm wanting to take a texture and blend it with a colour from the pixel buffer :

texture_colour*dst_colour + dst_alpha*dst_colour

and have:

GlEnable(Gl_Blend)
glBlendFunc(GL_Dst_Color,GL_Dst_Alpha)

the 'texture_colour*dst_colour' works fine but the ' dst_alpha*dst_colour' part seems to add 'dst_alpha*white'

Anyone got any ideas what I'm doing wrong?

ninogenio

hmm im not really sure what you mean i usually do this for my blending.

glColor4f 1.0, 1.0, 1.0, 0.4
glEnable GL_BLEND
glBlendFunc GL_SRC_ALPHA, GL_ONE
Challenge Trophies Won:

Stonemonkey

ty ninogenio, it's for my lighting rather than alpha blending though and i've got it working now. Was something I was doing with multitexturing in an earlier stage.

Jim

Nino, you should probably use
glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
otherwise you'll end up with a bit of a glow effect - or perhaps that's what you wanted in the first place?
ie. right now you have (0.4 in the alpha colour)
pixel = 0.4 * src + 1.0 * dst.
which is src and dst are both white would give you 1.4 * white (ie. overbright, so some colours near-white will end up white).
In the version I posted you have
pixel = 0.4 * src + (1.0-0.4) * dst.
which has a maximum of 1.0.

Jim
Challenge Trophies Won:

ninogenio

ahh right what am i thinking your right jim.

cheers for the pointer btw ;)
Challenge Trophies Won: