17

How can I add a glowing effect to a line that I draw? I'm using OpenGL for Linux.

bobobobo
  • 64,917
  • 62
  • 258
  • 363
joi
  • 307
  • 1
  • 2
  • 11
  • 2
    This is commonly called "adding [bloom](http://en.wikipedia.org/wiki/Bloom_(shader_effect))", to aid in your search. There is a nice section in how to do it [here](http://ofps.oreilly.com/titles/9780596804824/chadvanced.html#fig-BloomTriptych) – bobobobo Dec 21 '12 at 19:29
  • There is also a great summary of glow effects [here](http://prideout.net/archive/bloom/) – bobobobo Jan 09 '13 at 22:05

4 Answers4

10

You can implement the radial blur effect described on Nehe Lesson 36. The main idea is to render the drawing to a texture, and do that N times with a small offset after each render, until the drawing is ready to be copied to the framebuffer.

I've written a small demo that uses Qt and OpenGL. You can see the original drawing (without the blur) below:

enter image description here

The next image shows the drawing with the blur effect turned on:

enter image description here

I know it's not much, but it's a start.

karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • 1
    I wasn't able to edit the answer, but I think the correct path has been changed to https://github.com/karlphillip/GraphicsProgramming/tree/master/qtLogoBlurGL – Saeed Masoomi Jan 16 '23 at 20:10
8

I too once hoped there was a very simple solution to this, but unfortunately it is a little complicated, at least for a beginner.

The way glowing effects are implemented today, regardless of API (D3D,OpenGL) is with pixel/fragment-shaders. It usually involves multiple render passes where you render your scene, then render a pass where only "glowing objects" are visible, then you apply a bloom pixelshader and compose them together.

See the link provided by @Valmond for details

Edit:

It should be added that this can be achieved with deferred rendering, where normals, positions and other information like a "glow flag" is rendered to a texture, i.e. stored in different components of the texture. Then a shader will read from the textures and do lightning computations and post-processing effects in a single pass since all data it needs is available from that rendered texture.

edvaldig
  • 2,301
  • 16
  • 17
5

Check this out : http://developer.download.nvidia.com/books/HTML/gpugems/gpugems_ch21.html

It explains easily how to make glow effects.

Robadob
  • 5,319
  • 2
  • 23
  • 32
Valmond
  • 2,897
  • 8
  • 29
  • 49
  • That really doesn't explain much about how to do it. It just talks about the process and not the actual implementation –  May 21 '15 at 11:55
1

Without using shaders, you might also try rendering to texture and doing a radial blur. As a starting point check out NeHe-Tutorials.

Zappotek
  • 344
  • 2
  • 5