Turning day to night and other Unity lighting tips

I found a thread on the Unity forums on lighting tips a while ago that had many good suggestions and came up with one I posted there that people may find useful: 

I have been playing a bit with the lighting using the deferred lighting rendering path and dual lightmaps. I played around with a technique to make it go from day to night with the same lightmaps by changing the directional light color and using fog. This is just an experiment so there could be issues with this I have not hit yet and any of you pros please point out if this is the right way to do it or not. Maybe there is a better approach – I am still learning. So here goes:

 

I have a daytime screenshot:

 

screenshot2_day  

It is as I mentioned before, setup in deferred lighting with dual lightmaps. I have a another blog entry on this and bump mapping terrain if you are interested.

 

Here is the night screenshot:

 

screenshot2_night

 

It shows the result of what I am going to describe next. So the way I did this was to do two things.

  1. Change your fog, or maybe set your fog (in rendering settings) to Exp2, change the color to something that is nearly black. I did black with a hint of blue in it (for moonlight) – 0,0,35,255. Now adjust the density to your liking, i ended up with 0.0175. Now if you want it semi dark you can adjust both the color and density to get it right.
  2. Change the color of your directional light source to be something that is the same as the fog, basically black with a hint of blue. I went with something a little brighter to give some more moonlight effect – 0,0,70,255. This can also be adjusted up to make it lighter.

Anyway that is it. You could probably make it dusk or maybe a blood moon with red, whatever. You are dealing with your ambient light and the light baked into your maps, so it may only work if this was generally white to begin with. Also you have your shadow distance in the equation. Mine is setup rather far so depending on that it may not work well either.

I made a third screenshot with fire:

 

screenshot2_night_fires

 

It tests out some point sources to see how it would look. Also it shows the issue with particle effects and SSAO in the fire in front of the rocks. If you didn’t know about that it is something to be aware of for any particle effects (possibly only semi-transparent ones, I don’t remember).

 

I would think you could easily setup this effect using scripting and possibly interpolating values to give you a day to night transition. You won’t have the sun moving because your lightmaps are prebaked, but it could work to simulate an afternoon to evening effect maybe. Also there is no cost to doing this because you are just changing colors – the fog will be a cost if you are not already using it though.

Sorry guys I forgot to mention this is obviously all pro stuff, i don’t know how this would work in forward with a single lightmap. I guess it would be like the far lightmap in my scenario. But you are blocking/blending this out with fog while the near lightmap has the light integrated into the rendering. You may have to really use a lot of fog and ruin the effect in the forward rendering path with one lightmap.

I would love some ideas from people who really know how to make a scene dramatic with lighting and color.  This is something I want to definitely learn and incorporate into AOS.

My philosophy with the game is to have smaller very high quality scenes with dense detail where there is a lot to explore (not space wise) and many things to discover.  Each small scene will be a mini-story in a sense and there will be a fairly large number of these smaller more detailed scenes that are strung together to provide the overall story flow and variability in the story based on actions and paths taken.

Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *