Hello Guest

Author Topic: Easy way to have shader create red outline around sprite?  (Read 4995 times)

ItsMeAlan

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 22
    • View Profile
Easy way to have shader create red outline around sprite?
« on: October 25, 2013, 11:51:51 pm »
In my game I want to indicate that the player is able to interact with an object by having a glowing red outline appear around it, pulsating in color. I want to do this with code so I can slap it on different objects with several frames of animation without having to come up with a ton of new art assets. Is there an easy way to do this with shaders?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Easy way to have shader create red outline around sprite?
« Reply #1 on: October 26, 2013, 12:22:36 am »
If you place multiple copies of the sprite behind the main one, with a shader that draws a solid colour but uses the alpha channel, you should get an outline. You don't want to do this on big sprites though, as there will be a fair bit of increased overdraw there.

ItsMeAlan

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Easy way to have shader create red outline around sprite?
« Reply #2 on: October 26, 2013, 09:02:20 pm »
Yeah, I do have some pretty big sprites with several lengthy different animation clips, and this is a mobile game so I'm striving to keep everything optimized. Do you think it's possible to do with just a custom shader?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Easy way to have shader create red outline around sprite?
« Reply #3 on: October 26, 2013, 09:46:03 pm »
Not just with a shader. You could do it as I suggested above, shader + multiple copies of the sprite. I don't know how bad the impact will be on perf.