Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Add a glow  (Read 5556 times)

0 Members and 1 Guest are viewing this topic.

TestZombie

  • Newbie
  • *
  • Posts: 11
    • View Profile
Add a glow
« on: January 24, 2016, 09:02:09 am »
So basically what I've been looking for for quite a while is a way to "add a glow" to specific sprites, shapes (ie sf::RectangleShape), and text. I don't know what direction to go to get what I'm looking for, or if it is even possible. At first I thought that I would need to use a bloom or a blur shader, so after looking into it for quite a while I never found something that looked like what i wanted to achieve, they only affected the actual texture itself, not the space around it. Then I found bloom post effects, that affected the area outside of the sprite/shape, but it had to be applied to everything that was being drawn as far as I could tell. I did find a "tutorial" that simply made a glow sprite and drew it on top of the sprite with the "glow", but i feel like this could be done without 2 textures for every sprite, also it wouldn't work for shapes or text. Answer is probably just shaders, but I've been looking for longer than I'd care to admit, so I'm here now. Sorry if off topic. Thanks in advance.

tldr
I want the after, for specific things (not everything on screen to have a glow, just a few sprites/text/shapes) , how do I achieve it, and where should I start?
« Last Edit: January 24, 2016, 09:13:34 am by TestZombie »

Resethel

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Re: Add a glow
« Reply #1 on: January 24, 2016, 09:15:55 am »
It seems not to be something easy to achieve as you said :/
It may require multiple shader passes, to filter them then applying the effect on them. Or you could render to-glow objects on a renderTexture and apply glow on them.
Try to search things around gaussianBlur shader, or bloom effect, it should help you achieve something close from what you want, assuming you've not already try that  ;D


Sorry for not being of very helpful :(, I'm no shader expert :/
« Last Edit: January 24, 2016, 09:19:41 am by Resethel »

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: Add a glow
« Reply #2 on: January 24, 2016, 10:46:04 am »
Your best bet is probably the bloom shader route. With a little work you can use it to apply a glow to only specific sprites (this is the technique I used in ). Normally you would render the entire scene to a buffer which you would then pass through the bloom shader process ie blurring the buffer and rendering it back on top of the scene additively. The trick is to render the scene to two buffers - one for non-glowing objects and one for the rest. Pass the buffer containing the objects you want to glow through the bloom process, then render that on top of the buffer the buffer containing the non-glowing objects to get your final scene. It sounds quite intensive but with good culling and vertex array optimisation modern hardware has no problem with this at all :)

TestZombie

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Add a glow
« Reply #3 on: January 24, 2016, 10:53:56 am »

Thank you both for the ideas, I think I understand what i need to do now.