Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am wondering what the best way to approach a "lighting" effect in 2D games is. For instance, if my main character is glowing, what techniques can I use to complete the visual effect of the character glowing when it is near other objects which would be affected by the light?

share|improve this question
up vote 36 down vote accepted

You could overlay a simple glow effect texture with soft transparent edges. If you want lighting/shadows similar to what you may find in a 3d world you could do something like this: However, if you are new to HLSL, then that may be a little bit too much.

edit: I stumbled onto a nice HTML5 2d light tutorial

share|improve this answer
That link is exactly what I was looking for. I can't thank you enough; this is extremely helpful. – Christopher Horenstein Sep 30 '10 at 15:17

There is an open-source XNA project which is an excellent library and implementation of 2D lighting that happens to be compatible with XNA 4.0's Reach profile - Krypton XNA.

share|improve this answer

You would need a postfilter shader effect written in HLSL or GLSL. The shader would receive the player coordinates and modify the brightness for all pixels in a certain range. XNA supports 2D shaders quite good.

Another solution would be to simulate brightness by using a texture with an alpha-channel. The texture would be mostly black except for a transparent spot in the middle. This texture we be an overlay over your game screen with the transparent spot centered on the 'glowing' player character. Old adventure games used this technique to simulate flashlights.

share|improve this answer

After some searching, this blog seemed like a good start:

be sure to read the comments because there are some improvements there, but the blog post will get you started :).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.