Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add glow to Image (Actor) in LibGDX

Tags:

libgdx

Is it possible to add a glow to the outline of an Image? I know I can do this by adding an additional "glowed" version of the image and switching to it when desired, but since there are many different shapes in my game, I would prefer the glow to be done programmatically. How can I do this?

like image 850
asherbret Avatar asked Jul 03 '15 17:07

asherbret


2 Answers

As @Metaphore mentioned, shaders are indeed the best option I found. I've succeeded in adding an outline to any desired image in my game by following this article and by getting crucial information from asking a follow up question.

like image 127
asherbret Avatar answered Nov 15 '22 11:11

asherbret


The only way to do this is to use your own pixel shader when drawing this particular image.

You can find a lot of glow effect shaders on the net and there are may tutorials how to use them as well. You may check official LibGDX article on this topic https://github.com/libgdx/libgdx/wiki/Shaders

However, I'd not recommend you follow that way, because using different shaders for drawing single images will make you render cycle code much more complicated and less optimal. So either you will compromise on it, or just find easier way to achieve such behavior without shaders (I mean draw it statically somehow).

like image 25
Metaphore Avatar answered Nov 15 '22 11:11

Metaphore