Glow shader limited by the texture area

Glow shader limited by the texture area

I'm working on a glow shader (for 2D engine Futile relying on Unity). It works OK but the effect is limited by the texture area. Except from adding a lot of empty pixels around the textures (which would result in un-optimized/too big texture atlases), is there a better solution to cope with this problem? I'm quite new with shaders so maybe this is a classic problem with some well known solutions, maybe I'm not searching with the right keywords.

Solutions/Answers:

Answer 1:

You don’t outline directly on the object itself, but do the outline in a post process step.

  1. Draw the scene, as if there was no outline.
  2. Draw the object(s) you want outlined to a new screensized texture.
  3. Apply the outline shader you already use to combine the images.

You may want to change the shader, so it draw the outline to the screen, without drawing the object itself; since you can draw the object in step 1, the outline will show up nicely anyway.

This has the benefit that if the object is obscured the outline will show the entire object. For example when the wizard is behind a tree, the tree will show but the outline shows the entire wizard. This is often used in games where hilighted objects may be hidden depending on the camera orientation.

References