• Advertisement
Sign in to follow this  

Transparency/Blend Issues for Water

This topic is 2511 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.glBlendFunc( Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA );

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.glEnd();

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:

[attachment=1820:CorrectRender.png]


Incorrectly Rendering:

[attachment=1821:IncorrectRender1.png]


(and further rotating to incorrectly render):

[attachment=1822:IncorrectRender2.png]


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

  • Advertisement