• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Advice on making a glow effect?

N

Noba

Guest
So I've basically scoured the internet looking for this, and for some reason have come up empty. Maybe it's my choice of words, I dunno. Seems like an easy thing to find though...

I'm looking for a glow effect, something similar to the neon signs you find. I have a general idea of what NEEDS to happen, as in colouring the existing sprite white and then creating the glow effect around it using various levels of opacity with the same colour as the existing sprite, but I can't seem to figure out how it would be done actual code wise. The only reason I'm thinking of doing this with shaders is because it needs to be done on every sprite, so I'm assuming that would be a more optimised way of doing it.
 

johnwo

Member
You draw the parts which you want to glow onto a surface, then manipulate the surface and blend it with the application surface by drawing it on top of it; this way you have for example have masks, which affect the glow (player/enemies/etc. going in front of the glowing object, etc.).
Use shaders for this, as it is much better for performance than doing it through non-shader surface manipulation.

EDIT:

Found this on the markedplace; It might help.
 
N

Noba

Guest
You draw the parts which you want to glow onto a surface, then manipulate the surface and blend it with the application surface by drawing it on top of it; this way you have for example have masks, which affect the glow (player/enemies/etc. going in front of the glowing object, etc.).
Use shaders for this, as it is much better for performance than doing it through non-shader surface manipulation.

EDIT:

Found this on the markedplace; It might help.
Yeah I was talking about using shaders, but the thing is I'm completely stumped on how to use GLSL or whatever it's called, and tutorials just confuse me further.

Edit:
Thanks for that, I'll try it out!
 

johnwo

Member
When introducing people to shaders, people often start with something like:
"Look at the (fragment) shader-code and think like this: This code is executed for every fragment(pixel) of the image I want to draw."

This is however a very simplified view of (fragment) shaders.

Fragment shaders are most commonly used in GM, so the vertex-shader is mostly just a passthrough shader.

The shader above should be enough to get you started, and would be a great example fragment-shader code to learn from.


How to acomplish your goal with the shader from the markedplace:
Create a surface.
Set current surface to newly created surface.
Set Bloom shader with shader_set(shader);
Set parameters for the shader with shader_set_*(arguments);
Draw what you want to "glow" onto a surface.
Reset shader.
Reset target surface.
Draw surface.
 
If you want to keep this effect dynamic, you need to use surfaces and shaders as was mentioned. Just mind that this shader is a single pass blur shader and thats the most inefficient but simplest way to do it.

If you want to do something better you will need a few days to learn shaders though. If you're up for that I do have a tutorial series on youtube linked in my signature. You'd have to watch it all from the first video up to the blooming video to really understand or you wont be able to fix all the problems you'll encounter.

Dynamic glows or blooms are no easy thing to do ;)
 
D

dannyjenn

Guest
I know nothing about shaders, but a fake bloom effect can be done with surfaces (not sure how fast it would run though).

What you need to do is draw all the sprites to the surface, then duplicate the surface, and then blur the copy somehow (I think shrinking it down and then scaling it back up should make it sufficiently blurry), and then draw the first surface to the screen and then draw the second surface (the blurred one) over top of the first but give the second one a reduced alpha and use the additive blend mode.
 
Top