I'm currently trying to implement a type of "smooth" lighting. How can I achieve lighting which looks like this:


Using OpenGl. I've attempted to use blending modes and have come very close to making it work but it came out like this: https://pbs.twimg.com/media/A1071viCEAAlFmJ.png

Edit: The technique usedis drawing the lighting image (a white gradient) then drawing all my images using the blending effect glBlendFunc(GL_DIST_COLOR,GL_ZERO) however the images come out slightly transparent as shown previously I also have no control of how dark the black background is.

and I also wasn't able to change the alpha of the black background which I want to be able to do.

Could I get a few pointers in the right direction?

  • 1
    \$\begingroup\$ From the screenshots it's hard to understand what your problem is. Could you describe more what is wrong with your own result and what would you like to achieve? \$\endgroup\$
    – msell
    Oct 21, 2012 at 6:00
  • \$\begingroup\$ Could you post what tutorial you are following or how you do it? \$\endgroup\$
    – kravemir
    Oct 21, 2012 at 9:20
  • \$\begingroup\$ This question seems to be utterly of no use anymore due to the fact that one of the linked images is not available anymore. \$\endgroup\$
    – dot_Sp0T
    May 30, 2017 at 5:31

1 Answer 1


The problem with using glBlendFunc(GL_DIST_COLOR,GL_ZERO) multiple times is that you'll only be able to take away light, not add more light to the scene - which will be a problem as soon as two or more light overlap. You can fix this problem by rendering all the lights additively to an offscreen buffer and then drawing the whole thing at once after finishing the rest of the scene.

To create and maintain an offscreen buffer, you can use an OpenGL Framebuffer Object as described here: http://www.opengl.org/wiki/Framebuffer_Object. You can essentially draw on it the same way you can draw to the backbuffer / screen. For accumulating all the lights there, you can use a simple additive blending mode:


which will also allow you to use the alpha channel of the light.

  • \$\begingroup\$ What would you use to draw? A white circle texture? \$\endgroup\$
    – jjxtra
    May 29, 2013 at 19:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .