Advertisement Jump to content
Sign in to follow this  

Transparency/Blend Issues for Water

This topic is 2845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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.

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 );

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
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!