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'm trying to learn about dynamic shadows for 2D graphics. While I understand the basic ideas behind determining what areas should be lit and which should be in shadow, I don't know how I would "lighten" a texture in the first place.

Could you go over various popular techniques for lighting a texture and what (dis)advantages each one has? Also, how is lighting a texture with colored light different from using white light?

share|improve this question
OpenGL or DirectX?? – kravemir Aug 4 '12 at 14:20
@Miro Those are libraries, not techniques. I am curious about what is actually done to make a texture lighter or change color depending on the color of the light. – Paul Manta Aug 4 '12 at 14:31
@Paul Manta he is probably asking which you're using. – Luke B. Aug 4 '12 at 18:30

The most common lighting model is Blinn Phong and Wikipedia has also this list of lighting techniques.

Lighting with textures is same, but you have diffuse (specular) color stored in texture instead of per vertex color.

Also, how is lighting a texture with colored light different from using white light?

Same as in real. If you lighten white paper with green light it will reflect green light so paper will look green, but if you'll lighten red paper with green light it won't reflect green light (just little bit, but that doesn't matter).

share|improve this answer
About that last bit regarding red light on a green body. Should the body be black with a very light touch of red? The reason I would expect this to be true is because it does not absorb the red light (thus it gets scattered in all directions), so the body appears to be black. The light touch of red would be because of the light rays that happened to be perpendicular to the object and have returned to the light source. – Paul Manta Aug 5 '12 at 15:11

Bump mapping is one technique. It creates dark and light areas on a flat texture that would normally be the same brightness.

This requires the use of a pixel shader,A bump(normal) map to determine normals. And the texture you want to apply the bumps.

With bump mapping you could make a flat drawn cylinder actually look round with the correct normal map. You also need to position you light source in your 2D space. It doesn't have to be an actual light source as you can feed any coordinate into the shader without one. But it will look like you have a light source.

This tutorial helped me understand it the most. I still couldn't make it from scratch.

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.