Jump to content

  • Log In with Google      Sign In   
  • Create Account


Sprite with alpha Blending in 3D world


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Papi93   Members   -  Reputation: 107

Like
0Likes
Like

Posted 14 August 2013 - 05:07 AM

Hi,
 

I'm working on a game in a 3D world with elements 2D only (Like Don't starve game) for Android and IOS.

Currently, I've managed "Sprite" without alpha blending, I've just put a condition in the pixel shader to test if pixel alpha channel is null:
 

if ( texture.a < 0.5 ) discard;

Everything working here. (On old devices like an HTC desire mobile, this condition "destroy" framerate but it's another problem :/)
But recently, I've tried to had another Sprite with AlphaBlending activated (The character in the video):

glCheck( glEnable(GL_BLEND) );
glCheck( glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ) );
glCheck( glDisable(GL_DEPTH_TEST) );

My sprite transparency is ok but it is now in front of everything in the scene. (Probably due to glDisable(GL_DEPTH_TEST)).

How can I handle depth with alpha blending activated?

Here is a video to show the problem:
 

T
hanks for your time!



Sponsor:

#2 _greyfox()   Members   -  Reputation: 1133

Like
0Likes
Like

Posted 14 August 2013 - 09:19 AM

I don't understand why you disable GL_DEPTH_TEST.

 

Replace glCheck( glDisable(GL_DEPTH_TEST) ); with glCheck( glEnable(GL_DEPTH_TEST) ); and everything should be fine.


“There are thousands and thousands of people out there leading lives of quiet, screaming desperation, where they work long, hard hours at jobs they hate to enable them to buy things they don't need to impress people they don't like.”― Nigel Marsh




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS