So here is what I am trying to do. Given irregular polygon (on the left) I would like to be able to create a shader that would resemble Photoshop inline glow effect with opaque fill (on the right).

enter image description here

Creating similar effect for 3d object I can achieve with Fresnel function. However, I am not able to do it for a flat surface of any given irregular 2d polygon.


I am planning on using Voronoi method to generate polygons and then connecting individual polygons to territory shapes based on which player owns them. Which, then will have border material applied. What I need is effectively border (or territory) shader. That means shader has to work for more irregular shapes, like the one below.

enter image description here

  • 1
    \$\begingroup\$ This will require either: 1) rendering your polygon to an intermediate buffer to blur, then using the fuzzy edges from that buffer as a glow weight in a subsequent pass, or 2) encoding an edge proximity or pseudo-normal into the vertices and using the interpolated result in the fragment shader. Is one route or the other more practical for your use case? \$\endgroup\$ – DMGregory Nov 30 '17 at 1:09
  • \$\begingroup\$ Can you maybe modify this one to suit your needs? \$\endgroup\$ – John Hamilton Nov 30 '17 at 11:35
  • \$\begingroup\$ @DMGregory I guess either method would do. Which one is easier? Would you mind elaborating bit more on either (both) of them. \$\endgroup\$ – IndieForger Nov 30 '17 at 16:28
  • \$\begingroup\$ @JohnHamilton I think it looks promising. I will try to dig into it and share my finding in few days. Would you be able to assist with that a bit? I am really open to and would appreciate any suggestions. \$\endgroup\$ – IndieForger Nov 30 '17 at 16:32
  • \$\begingroup\$ To be honest, both routes are kind of annoying in different ways. ;) Can you tell us more about how these shapes are used in your game, or how they're generated? That context might lend itself better to one approach or the other. Of course, you could also just bake this glow in with Photoshop in advance if the sprites are available at edit time — much easier than doing it dynamically. ;) \$\endgroup\$ – DMGregory Dec 1 '17 at 2:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.