PDA

View Full Version : Bad Blending



glBomb
08-22-2006, 12:11 AM
I am trying to make this mod for Age of Empires & here you can see a isometric map/terrain & a castle on it. Now the art is stored in rectangular pictures with the white regions being masked to get irregular outlines. To mask the white regions i gave those pixels an alpha of 0 & the remaining colors an alpha=255 & converted them to textures in Orthographic view. The tiles are also stored similarly . Then i enabled alpha blending with the blend function
glBlendFunc(GL_SRC_ALPHA,GL_SRC_COLOR)
Now the castle is not fully opaque(left).

http://img213.imageshack.us/img213/8761/ps3vb0.jpg

With the following blend function
glBlendFunc(GL_SRC_ALPHA,GL_ONE)
its worse as the castle is not only transparent but the colors are brightened where the terrain intersects(right).

I cannot disable blending because then the white regions will show up around the sprites. I dont want to use alpha testing because i want to able to vary the alpha for certain things like water & clouds. Can turning on & off alpha testing as required achieve this or some sort of masking/stencil buffer whatever. I do want to retain the ability of varying alpha to fade objects in/out.

gemelli_d
08-22-2006, 05:59 AM
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
should be the solution

glBomb
08-23-2006, 05:01 AM
Hey that worked perfectly...dunno how i missed it...thanks a lot!!