Sign in to follow this  

Transparency/Blend Issues for Water

Recommended Posts

Hi all,

Long-time reader, first-time poster. I'm building a 2.5D engine (3D world, 2D sprites with billboarding/tiles). I'm having issues with some water and blending functions. To keep it simple, the world is divided into tiles, ala most 2D tile-based games, and water is assumed to be drawn on the Z-plane wherein Z = 0.

[code] Gl.glEnable( Gl.GL_BLEND );
Gl.glEnable( Gl.GL_TEXTURE_2D );

Gl.glColor4f( 1.0f, 1.0f, 1.0f, 0.9f );

float TextureX1 = TileSurface.X + ( Video.AnimationFrame / 20 ) * ( TileDimension * 4 );
float TextureX2 = TextureX1 + TileDimension;
float TextureY1 = TileSurface.Y;
float TextureY2 = TileSurface.Y + TileDimension;

Gl.glBegin( Gl.GL_QUADS );

Gl.glTexCoord2f( TextureX1, TextureY1 );
Gl.glVertex3f( pX, pY, 0.0f );
Gl.glTexCoord2f( TextureX1, TextureY2 );
Gl.glVertex3f( pX, pY + 1.0f, 0.0f );
Gl.glTexCoord2f( TextureX2, TextureY2 );
Gl.glVertex3f( pX + 1.0f, pY + 1.0f, 0.0f );
Gl.glTexCoord2f( TextureX2, TextureY1 );
Gl.glVertex3f( pX + 1.0f, pY, 0.0f );


Gl.glDisable( Gl.GL_TEXTURE_2D );
Gl.glDisable( Gl.GL_BLEND );[/code]

It looks fine when I'm looking at it from the Western Hemisphere; when viewing from the Eastern Hemisphere, I seem to have issues. Note the compass always points North.

Correct Rendering:


Incorrectly Rendering:


(and further rotating to incorrectly render):


I read something about GL wanting to make sure that things were drawn underneath before blending. I thought this *could* potentially be an issue, but since I draw from left -> right, top -> bottom (w -> e, n -> s) this doesn't seem to make any sense; if anything it should have issues going in the reverse order. I've tried to reverse the drawing and make sure that the water was drawn first, then tile and vice-versa.

Any thoughts? Sorry, I imagine this is probably a very nooby question.

Share this post

Link to post
Share on other sites
I feel really retarded. Finally found [url=""][/url], which really helped. Just did simple fix one and made sure the world was drawn first, then repeated drawing the map once again with the next layer. Oy. Not perfect, but I'll take it for now.

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