Sign in to follow this  
MARS_999

Correct way to do transparent water?

Recommended Posts

MARS_999    1627
I have this code to try and do transparent water and getting the wrong effect? I am using a .tga water texture with alpha but not sure if water texture I am using is correctly setup for this...
glActiveTextureARB(GL_TEXTURE0_ARB);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, textureObject[WATER]);

	glEnable(GL_BLEND);
	glEnable(GL_ALPHA_TEST);
	glBlendFunc(GL_ONE, GL_ONE);
	/*
	glActiveTextureARB(GL_TEXTURE1_ARB);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, textureObject[WATER_DETAIL]);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
	glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);
*/
	glBegin(GL_QUADS);
	glMultiTexCoord2f(GL_TEXTURE0_ARB, 0.0f, 0.0f);
	/*glMultiTexCoord2f(GL_TEXTURE1_ARB, 0.0f, 0.0f);*/ glVertex3f(-size, waterHeight, -size);
	glMultiTexCoord2f(GL_TEXTURE0_ARB, 0.0f, 1.0f);
	/*glMultiTexCoord2f(GL_TEXTURE1_ARB, 0.0f, 1.0f);*/ glVertex3f(-size, waterHeight, (MAP_Z * SCALE_FACTOR) + size);
	glMultiTexCoord2f(GL_TEXTURE0_ARB, 1.0f, 1.0f);
	/*glMultiTexCoord2f(GL_TEXTURE1_ARB, 1.0f, 1.0f);*/ glVertex3f(size + (MAP_X * SCALE_FACTOR), waterHeight, (MAP_Z * SCALE_FACTOR) + size);
	glMultiTexCoord2f(GL_TEXTURE0_ARB, 1.0f, 0.0f);
	/*glMultiTexCoord2f(GL_TEXTURE1_ARB, 1.0f, 0.0f);*/ glVertex3f(size + (MAP_X * SCALE_FACTOR), waterHeight, -size);
	glEnd();
	
	glDisable(GL_TEXTURE_2D);
	glActiveTextureARB(GL_TEXTURE0_ARB);
	glDisable(GL_TEXTURE_2D);
	glDisable(GL_ALPHA);
	glDisable(GL_BLEND);


Maybe I am not even close to being right? Thanks for the help...

Share this post


Link to post
Share on other sites
MARS_999    1627

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);



This is what I am using now. And still looks wrong. If the water is over my terrain its somewhat transparent but the water over nothing is black. The texture is of water, and I see none of that on my terrain...

Share this post


Link to post
Share on other sites
Basiror    241
Quote:
Original post by MARS_999
*** Source Snippet Removed ***

This is what I am using now. And still looks wrong. If the water is over my terrain its somewhat transparent but the water over nothing is black. The texture is of water, and I see none of that on my terrain...


as far as i know you only render transparent water if you have terrain underneath it otherwise disable alpha blending

and yes it is wrong maybe use another clearcolor

do you use a skybox or skydome?

Share this post


Link to post
Share on other sites
MARS_999    1627
Quote:
Original post by Basiror
Quote:
Original post by MARS_999
*** Source Snippet Removed ***

This is what I am using now. And still looks wrong. If the water is over my terrain its somewhat transparent but the water over nothing is black. The texture is of water, and I see none of that on my terrain...


as far as i know you only render transparent water if you have terrain underneath it otherwise disable alpha blending

and yes it is wrong maybe use another clearcolor

do you use a skybox or skydome?


Hey Basiror, long time no see, anyway, I am using a skyplane. I am debating just using a vertex program and a fragment program to do the water with and use a bumpmap.... I would be interested in seeing any new screenshots of you terrain engine... since last time. I can send you mine if you would like...

Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this