Android - Partial Transparency

Started by
1 comment, last by greerws 11 years, 9 months ago
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
Advertisement
There are a few ways you can do this.

You can first render the wall normally, then render the character without depthtesting (fairly simple but probably not quite the effect you're looking for)

you coukld also Render the wall twice, first at X% opacity without depthwrites, then render the character, then render the wall again at 100-X% opacity and additive blending.

Those two effects basically just make the character visible through the wall and might not be what you want.

You could also project the character onto the wall (in black or grey) (or the walls position rather) (towards the camera) and write that to a separate otherwise white texture, apply blur to the texture, render the character normally and finally render the wall using the greyscale characteroutline texture as the alpha channel. (There are probably faster ways to do this aswell).

Another option could be to render a scaled up version of the character to the stencil buffer and use that for a stencil test when you render the wall (works with fixed function), or render to a texture and process in the pixel shader (to get fancy edges for example), (With ES 1.1 the options are a bit limited, but with 2.0 you can do pretty much anything)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Simon,

I appreciate the quick response. I think your last idea is even better then what I was originally picturing. I think I'll give that a try and see how it works out.

Thank you!

Shawn

This topic is closed to new replies.

Advertisement