Jump to content

  • Log In with Google      Sign In   
  • Create Account

Android - partial transparency


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
2 replies to this topic

#1 Shawn Greer   Members   -  Reputation: 148

Like
0Likes
Like

Posted 02 July 2012 - 01:55 PM

Hello all. I'm laying out the design for a game on the Android using openGL ES, and I've stumbled upon an issue that I can't seem to find a solution for. I'm looking to be able to draw something on the screen, like a wall, then have a character pass behind the wall. When the character is behind the wall, I'm looking to apply an auro of transparency on the wall in front of the character, enabling you to see the character behind, without making the entire wall transparent.

Any help anyone could offer any help, or at least point me in the right direction, I'd greatly appreciate it.

Shawn

Edited by greerws, 02 July 2012 - 02:02 PM.


Sponsor:

#2 freakchild   Members   -  Reputation: 557

Like
1Likes
Like

Posted 02 July 2012 - 04:57 PM

Use the blend functions for transparency alone:

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

There are several blend functions so it might be worth reading up on them here.

If you're looking for an aura from transparency then you could also do something in the shader based around the incoming transparency value.

Bear in mind that for making the character go behind the wall, simple depth pixel tests might suffice for that. If depth fails, you could use the incoming transparency value to write your aura over the wall. You could also just use the painters algorithm (drawing in a particular order) to bring one or the other to the front.

You may also consider a render to texture pass for the wall layer. This would allow you to read that layer into your shader as a texture so that it could be taken into account along with the transparency value as you write your final image. This would certainly let you take the wall into account as you decide which pixel to write, but it really may be overkill.

For basic transparency alone though go for the basic blending above so you don't overwork the shader. The link above may lead you to a blending equation that keeps things simple.

Edited by freakchild, 02 July 2012 - 05:47 PM.


#3 Shawn Greer   Members   -  Reputation: 148

Like
0Likes
Like

Posted 02 July 2012 - 10:56 PM

Thank you for the quick response. I'll give some of these a try and see if I can generate the look I'm going for.




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