Water transparence problem

Hi,

I have a model with a ground and a river.
I want the water texture to be transparent and then to see the rocks in the river.
For that I render the scene first with the opaque textures (the ground) and then I make
glEnable(GL_BEND);
glDisable(GL_DEPTH_TEST);
and I render the triangles with the water texture.
The triangles are send to Opengl from the furthest to the nearest.

I init OPengl with
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

I use a glColor4f(1,1,1,0.5f);

But I can’t see trough the water.

Does someone have an idee of the problem ?

Thanks

Do you make a glTexEnv(GL_TEXTURE_2D, GL_MODULATE) and not a GL_REPLACE ?

Oups, of course I would like to say glTexEnvi(GL_TEX_ENV, GL_TEX_ENV_MODE, GL_MODULATE) which is done by default…

Don’t forget to turn on glColorMaterial (or just use the glMaterial functions to set the alpha value).

it’s strange: if I don’t disable the DEPTH_TEST & disable the lighting: it works !!!
Any idea ?

What about when both lighting and the depth buffer are disabled?

If it works in this case, then like Korval said, you need to use glMaterial instead of glColor.

j

>>it’s strange: if I don’t disable the DEPTH_TEST & disable the lighting: it works !!!
Any idea ?<<

read the FAQ (link first page)
basically unless youre using color_material. glColor…(…) commands have no effect when lighting is enabled.

You were right: i forgot to enable GL_COLOR_MATERIAL :slight_smile:
Thanks

But it still works only with DEPTH_TEST enabled.