Help with alpha Blending
Hi folks, im doing some simple alpha blending and it is giving me some serious head ache.
Hopefully someone can point me in the right direction.
Some background. I have a simple scene consiting of land, a river and a log on the river. I want to make my river to be transparent to give an illusion of water. Everything is textured.
Without alpha blending, everything works fine.
To enable alpha blending I perform the following:
glEnable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
Next, to make an object (my river) transparent, before drawing my quads i wrote:
glColor4f(0.0f,0.0f,0.0f,0.5f);
glBlendFunc(GL_ONE,GL_ONE);
Hurray, my river was now transparent runnuig along some land. On a side note, without the above 2 lines my water was magically transparent (by only enabling GL_BLEND).... this caused me to worry slightly.
However, I now need to place a log on the river and no matter what I do, the log appear 50% transparent, as in half of the log is opaque like I want, the other half has blending applied. The following picture describes the problem better:
What am I doing wrong, I tried to turn off blending for my log by using
glColor4f(0.0f,0.0f,0.0f, 0.0f);
This did not work.
I am construct my scene as follows:
Log
Land
Water
Please, anyone, i am going nuts over this :) Any help apprecicated.
Taz
Quote:Original post by irreversible
To turn off alpha blending, use glDisable(GL_BLEND)
But i want alpha blending to allow me to have transparent water?
Or am i incorrect here.
Kind regards
Taz
enable depth testing
disable blending
draw terrain
draw log
enable blending
draw water
OpenGL is a state machine - GL_BLEND is just a state that can be toggled at any time using glEnable() and glDisable().
disable blending
draw terrain
draw log
enable blending
draw water
OpenGL is a state machine - GL_BLEND is just a state that can be toggled at any time using glEnable() and glDisable().
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement