Off the back of this post in which I asked two questions and received one answer, which I accepted as a valid answer. I have decided to re-ask the outstanding question.

I have implemented light points with shadow casting as shown here but I would like an overall map light with no point/light source.

The map setup is a top-down 2-d 50X50 pixel grid.

How would I go about implementing a day/night cycle lighting across a map?

  • \$\begingroup\$ possible duplicate of How Do Day Night Cycles Work? \$\endgroup\$
    – House
    Oct 24, 2012 at 13:21
  • \$\begingroup\$ I did search i think that post relates more to 3-d. but i'm sorry if its duplicated :( \$\endgroup\$
    – LoveofSnow
    Oct 24, 2012 at 13:29
  • \$\begingroup\$ The concepts are the same. Changing the visuals of your game to represent more or less light. \$\endgroup\$
    – House
    Oct 24, 2012 at 13:32

2 Answers 2


You should take a look into ambient lightning. This means you set a light color which is applied to all elements. This could be done in several ways. If you are using a shader for postprocessing you can add it there as a parameter and just change it to simulate day and night cycles.

A nice example was shown here (its in german, but maybe the source will help you a bit). It basically uses blend states to mix up different render targets containing the light sources.


Thank you for your answer floAr I'm be up-voting your answer for giving me the term I was searching for:

Ambient lighting - lighting which is from no particular source but which is background lighting across all entities.

I've found this blog post with some very simple code which I'll be trying later.

this is the key for me:

new Color(ambientColor.R / 255f * ambient, ambientColor.G / 255f * ambient, ambientColor.B / 255f * ambient);

From the blog post:

(the approach is to modify the color of every sprite when drawing it)

Add to the top of your game class:

float ambient = 1f;  
Color ambientColor = Color.White;  

In the Update method:

KeyboardState c = Keyboard.GetState();  
if (c.IsKeyDown(Keys.Space))  
   ambient -= 0.01f;  
   if (ambient <= 0)  
      ambient = 1f;  

And finally, to apply ambient lighting to sprites:

Color drawColor = new Color(ambientColor.R / 255f * ambient, ambientColor.G / 255f * ambient, ambientColor.B / 255f * ambient); 
spriteBatch.Draw(mySprite, new Vector2(0,0), drawColor);  

As you see, it's very easy :) With this, you could simulate for example day cycle.


You must log in to answer this question.

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