Day/Night Cycle

This is part of a project I’m working on currently. I’ve managed to get a very smooth looking day/night cycle done. Look here:

http://web.lemuria.org/~tom/unity/estate/estate.php

The button on the bottom-right accelerates time. Keep it pressed, because otherwise time is real time and you’d have to wait the whole day. :slight_smile:

There are still errors in the skyboxes, that you’ll notice if you switch the camera view, and of course there’s nothing really to do, yet.

How does this work?

I have the same skybox in 3 different versions - day, night and dawn. An update timer calculates blending depending on time of day - during the day, you see the day skybox, during the night, the night one. For two hours around dawn, it will blend from day to dawn, then to night or vice versa.
At the same time, the sun is continuously moved also based on the current time.
As a small extra, the fire braziers on the courtyard are lit at dusk and extinguished at dawn.

It was an interesting experiment getting it all just right. :slight_smile:

Edit: Updated link.

Pretty nice. You might also want to change the light color and ambient light value over time for an extra bit of “oomph”, as seen in the scripts here.

–Eric

its nice work ,
i would suggest adding realtime shadows , which would clearly show the the suns angle and create little more realism.

also add some bakes contact shadows (occlusion or something ) , that would make the houses more grounded.

and maybe use a little glow on the textures to generate a haze effect when the sun is high.

Cheers

Steve

I only have the Indy, so no shadows, unfortunately.

I’m looking at the script you mentioned, Eric. I’ll incorporate some of it.

I’ve also had luck changing a slight tint to a fog color and the overall fog values to give a greater feel for day/night cycles.

New version up:
http://web.lemuria.org/~tom/unity/estate_test.html

Uses Eric’s ideas and allows you to rotate the current camera (that’s the button in the middle).

Skybox and lighting are not yet in perfect sync, I’ll fine-tune that when I come back from my holidays. :slight_smile:

The new version crashes Firefox. I tried 3 separate times, each time it loads the entire webplayer, then promptly crashes and sends a report. I’m using the latest version of FireFox 3.0.4 and OS X 10.4.11 on an iMac Intel Core Duo with 2 GB of RAM.

Edit: I just tried it again. First I cleared Firefox’s cache and then relaunched. Still crashed. I haven’t run into this issue in a long while, are you sure you didn’t leave something awry in your project?

I see no one has found a way to make grass light affected… :frowning:

If you use a lightmap to illuminate your terrain grass and detail maps will be effected by lighting (and all shadows that are baked into the lightmap).
look at the picture below: grass and details meshes (like the yellow weed) are lightened “correctly” by the terrain’s lightmap.

lars

108300--4141--$grass_shadows_294.jpg

but what if the light is always changing?

Than i guess you will need another engine: with realtime lighting on all objects/vegetation/… and a very fast graphics card… look at cryengine2 or dunia which drives far cry2.

Or you use different lightmaps.

different light maps you say? So would it be able to use a script to change the light maps at certain (rotations?!?) to replace the lightmap?

Multiple lightmaps is a good idea. If you could interpolate between two light maps (one for night, one for day) it would look even better.

Yes, I realized that after uploading.

Bug is fixed, but I forgot to upload it, and I’ve already left home for a week of holidays. So it’ll be updated next week.

Regarding the grass and tree problems: Yes, I’m looking for a solution for that. Obviously, it can’t stay this way.

New, bugfixed and much improved version up at:

http://web.lemuria.org/~tom/unity/estate/estate.php

That one works!

Some feedback:

The night skybox is awesome! Love the moon / cloud sky lighting!

Model and textures are very nice.

The cross fade transition is also nicely done.

I would disable the full screen option (right click menu) since your cross fades don’t work in full screen mode.

This scene just -begs- for real-time shadows!

Did anyone find a solution to switching lightmaps on the fly from a scipt??

Using multiple lightmaps for day/night cycle shadows is not very efficient. The amount of lightmaps required would be too many to generate and if you have too few, would not be smooth in terms of transitions.

Realtime shadows were built for this sort of thing.

You could just use a general ambient occlusion/overcast lightmap and do the rest realtime. With or without shadows - changing the fog and ambient colours should take care of most of it.

care to give some code :stuck_out_tongue: ?