Shader for glowing polygons

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
megalukes
Citizen
Posts: 94
Joined: Fri Jun 27, 2014 11:29 pm
Location: Brazil

Shader for glowing polygons

Post by megalukes »

Hi there. I was wondering if there's a shader for glowing polygons in Love. I'm programming a small geometry game in which I use love functions to draw complex polygons. Even though it's a simple game, I wish I could use a glow effect to make them look cooler.

For instance: I want to draw two rectangles using love.graphics.rectangle and then apply a glow effect on them, like this:
chrome_2017-06-23_20-34-11.png
chrome_2017-06-23_20-34-11.png (73.42 KiB) Viewed 2391 times
How could I do that?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Shader for glowing polygons

Post by raidho36 »

First of all, you need to know that shader effects only apply within the area of an object being rendered, everything outside of it is unaffected. If you draw a square, only pixels inside the square are affected. So if you'd use a glow shader, it would not glow outwards.

Second of all, try baking glowing effect into the sprite, or try making a composite sprite with a base part and a glow part. This is computationally cheaper and you can probably make it look much nicer in Photoshop than in GLSL.

Glowing effect in general is achieved by having a separate canvas just for glow effect. Once its filled with glow graphics, it's rendered on top of main scene. You can go with cheap bloom algorithm, i.e. take rendered scene and map colors from upper region of original brightness to full range of brightness (bottom part gets clipped and top part is smooth transition), then apply hefty amount of blur. You can use something more sophisticated, such as rendering custom glow sprites into glow canvas. When you're finished, you set additive blend mode (or whichever is best fitting) and render glow canvas full-screen on top of rendered scene.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 158 guests