1

I have researched and the methods used to make a blooming effects are usually based on having a sharp and blurred image conjoined to give the glow effect. But I want to know how I can make gl_lines(or any line) have brightness. Since in my game I am randomly generating a simple 2D terrain, I wish to make the terrain line segments glow.

lambda
  • 1,225
  • 2
  • 14
  • 40
  • So what's the problem? Can't you just re-draw the blurred terrain - maybe slightly brighter? – Nico Schertler Jun 08 '13 at 08:09
  • the terrain isn't static. The terrain is randomly generated through line segments. I am asking how to blur those line segments to give a glow to it. – lambda Jun 08 '13 at 08:12
  • possible duplicate of http://stackoverflow.com/questions/8293839/how-to-add-glowing-effect-to-a-line-for-opengl – Antti Jun 08 '13 at 08:13
  • Who says that the terrain has to be static? You can draw the terrain to the screen and a texture. Blur the texture and render the result to the screen. – Nico Schertler Jun 08 '13 at 11:12
  • Are you willing/able to use shaders? – Andreas Haferburg Jun 08 '13 at 20:01
  • I am willing to use something that doesn't slow down the program. – lambda Jun 08 '13 at 20:38
  • @AndreasHaferburg - modern opengl pretty much mandates shaders and there is no point of using any of the old fixed functionality pipeline. In this case you can even gain performance by skipping the rasterization step and directly use the shader with the "vertex" data. – dtech Jun 08 '13 at 21:52
  • @ddriver That's why I upvoted your answer. But I don't see the word "modern" anywhere in the OP. ;) – Andreas Haferburg Jun 08 '13 at 22:10
  • @AndreasHaferburg - well, he didn't explicitly specify he needs the old pipeline as people often do when that's the case. And usually that's due to outdated textbooks and other educational materials. So I assume that "modern" should be the default style of GL. – dtech Jun 09 '13 at 03:04

1 Answers1

2

Use a fragment shader to calculate the distance from a fragment to the edge and color the fragment with the appropriate color value. You can use a simple control curve to control the radius and intensity anlong of the glow(like in photoshop). It can also be tuned to act like wireframe visualization. The idea is you don't really rasterize points to lines using a draw call, just shade each pixel based on its distance from the corresponding edge.

The difference from using a blur pass is that you will first get better performance, and second - per-pixel control over the glow, you can have non-uniform glow which you cannot get by using blur because it is not really aware of the actual line geometry, it just blindly works on pixels, whereas with edge distance detection you do use the actual geometry data as input without flatting it down to pixels. You can also have stuff like gradient glows, e.g. the glow color is different and changes with the radius.

dtech
  • 47,916
  • 17
  • 112
  • 190