I'm currently experimenting with simple lighting in my game made with SFML and C++ (though I don't think that's relevant to the question). It's my first time messing with lighting in 2D, and my basic system is to:

  1. Create a lightmap
  2. Every frame, clear the lightmap and add all lights back to it (they move).
  3. Every frame, draw the lightmap to the window on top of the game and multiply the colors from both textures (the game texture and the lightmap texture). In SFML I do this by:

window.draw(lightMap, sf::BlendMultiply);

My issue is that my lights don't show up against a black background, which doesn't seem to make sense. It's as if that specific color (and colors close to it) just can't be illuminated. Is this because of how color multiplication works? If so, is there a workaround?

Example. The light from the lasers shows up towards the bottom of the screen, where the background is purpleish, but when the background becomes black, the light is no longer visible.



1 Answer 1


Yes, Black has a value of 0 for all color components, and your use of BlendMultiply means that anything multiplied by 0 is still 0. Try using a different blend mode -- Additive Blending tends to look reasonable for glow effects like these.

  • \$\begingroup\$ Hi Jimmy, thanks for the response. I have tried Additive Blending (I’m learning terminology as I go), but it seems to only be able to make everything lighter rather than starting dark and adding light. Basically, with BlendMultiply I can make the screen pitch dark and lighten it with the lights, but I can’t with BlendAdd. \$\endgroup\$ Nov 19, 2017 at 21:25
  • 1
    \$\begingroup\$ Hi panner, this is completely depending on the type of effect you're going for, but I would imagine the lightmap would really only be responsible for adding the glowing bits in your scene -- the rest of the canvas should already be "dark" before drawing in the lightmap. \$\endgroup\$
    – Jimmy
    Nov 19, 2017 at 21:31
  • \$\begingroup\$ I know nothing about sfml, but with directx you actually clear the background with a color which is a value of 4 floats. Maybe you can change this value from your black (0, 0, 0, 0) to a "solid" one (0, 0, 0, 1.0/255 - float/int) in this way you'll achive the effect you want if I've understood. \$\endgroup\$
    – Liuka
    Nov 20, 2017 at 22:43
  • \$\begingroup\$ Thanks Jimmy and Liuka. I just did a simple workaround by making the entire screen darker with a separate texture and then using BlendAdd, but yes Liuka, sfml does clear the screen with a color. That’s an interesting idea, I’ll try it out. \$\endgroup\$ Nov 21, 2017 at 15:57

You must log in to answer this question.

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