Sign up ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm looking to create a halo highlight around the selected objects in my game screen. The main platform is android, but I am writing an iOS version as well, updating it whenever I successfully add the next feature.

I am trying to ensure that the game is capable of working in both OpenGLES 1 and 2, but of course I expect v2 to have more effects eventually.

The effect I want to achieve is to have a halo around the edge of the selected object (I believe Diablo II did something similar). In theory my idea is to render the scene, enabling stencil ops when the selected object is rendered then enable stencil testing, disable depth and set an orthogonal projection and draw the halo colour 5 pixels larger in each of the X and Y dimensions from the object's centre with 0.2 alpha then successively draw again reducing the size and blending.

Using this method, I also need to figure out the most efficient way of determining the centre and extents of the objects.

EDIT: Another technique I just thought of after posting is, after the stencil op render, render a coloured ortho rectangle to texture through the stencil then shrink and re-enlarge the image to blur the edges then render the resultant texture back on top of the scene, around the stencilled area

  1. Are either of these a good/efficient way to achieve the effect? Is there a better/faster/more efficient/more common way of doing this?
  2. Should I bother doing it for v1 and make it a v2 only effect?
  3. Should I bother with v1 at all if I want these sorts of effects?
share|improve this question
I have a feeling the solution is going to be different for each of v1 and v2. I've got some great ideas for using shaders but I'll have to do something different for v1. – Ben Jaguar Marshall Jul 30 '12 at 2:54

1 Answer 1

up vote 0 down vote accepted

Are you using 3D? Then you could just add slightly scaled versions of the same object wich are coloured in your halo colour and have 0.2 alpha. Then just render the real object after all these halo-objects

share|improve this answer
That'll only work if the objects he's displaying are fully convex. If there are any concavities, they won't get highlighted correctly. – Raceimaztion Jul 29 '12 at 1:51
Good idea @Aron_dc, but issue there is that the halo would be in object co-ordiates and I need it in screen co-ordinates. Also, the edges may be at drastically different depths, so the halo may not be even. Would work well for a neon light effect though. – Ben Jaguar Marshall Jul 29 '12 at 23:46
@Raceimaztion, you have a good point there, although I think the stencilling may cancel it out, but I'm just theorising here. – Ben Jaguar Marshall Jul 29 '12 at 23:46
I have shipped commercial games using this approach, just scaling by a different amount based upon distance, to maintain an (approximately) constant outline width regardless of distance. (With that said, I would not use this approach today; using multiple render targets will be far more effective, and probably faster on modern video cards) – Trevor Powell Jul 30 '12 at 5:57
@Aron_dc I'm giving you the tick because you've lead me in the right direction. I'm using this principle with some adjustments. I'll be, for the moment, using GLSL to correct the final scale in screen units. – Ben Jaguar Marshall Aug 10 '12 at 6:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.