Monday, June 23, 2014

Time of day blueprint guide

This is a guide on how to use this blueprint:

After running the sample map, the first thing you'll notice is that the sun moves waaaay too fast.  To slow down the sun, change the "Time Speed" variable.  Time Speed is a ratio of game-time to real-world-time; e.g., setting it to 24 will make 24 game-hours go by in 1 real-world hour.

With that out of the way, let me go over how to set up this blueprint in your own maps:

Setting this blueprint up in your own maps

- Delete the default skydome;
- Drag-and-drop the day-cycle skydome into your map;
- Set the "Directional Light Actor (Sun)" variable to equal your sun lamp in the map;
- (Optional) Set the "Moon Actor" variable to your moon lamp in the map;
- Set your sun and moon lamps to "movable" and disable static shadows;
- (Recommended) In the World Settings, under "Lightmass," check "Force no precomputed shadows";
- Rebuild lighting.

That's it, you should be good to go!  I highly recommend using this setup with LPV GI, you can find more information on it here:

Quick breakdown of the most important properties

Default Hour - The time that we start at when we play the map;

Time Speed - Speed of time in ratio of game-time/real-world-time;

Sun Speed Curve - ADVANCED:  This curve gives you precise control over the movement of the sun vs. the actual time.  For instance, if you wanted to make days last longer, you could use this to slow down the sun for the duration of the day.  Just ignore this property if you don't need such functionality.

Moonlight Intensity - The brightness of the light from your moon actor; note that this must be set here, and not in the moon lamp's settings;

Use Day/Night - Uncheck this if you want to disable the dynamic features of the blueprint;

Display WorldTime - Logs the current time to the screen every frame, uncheck to disable.

Thursday, June 19, 2014

UE4 Time of Day Setup

My blueprint for a fully dynamic day-night cycle setup.  Download here.

Quick setup instructions:

- Extract archive;
- Copy the "Content" folder into your project folder (it should merge with the content folder already there);
- When it asks if you want to merge folders, say yes;
- Launch UnrealEd, and load the project you copied that folder to;
- Go to 'File > Open Level' and choose "TimeOfDayTemplate.umap" (it should be located under \YourProject\Content\Maps);
- Hit simulate, and watch the sun move!

Experiment with the properties in the blueprint.  I've written comments for all of them (I think), so it shouldn't be too hard to figure it out.  Quick tip: If you want to change the speed of time, "Time Speed" is what you're looking for.

For more details and information, see here:


Version 1.2, 6/23/14,
Added support for a moon;
Improved organization of variables, added new "ToD - Debug" section;
Fixed sun to move from East to West;
Sun's rotation is now calculated from a curve, use this to set sunrise/sunset times;
Added sample map;

Version 1.1, 6/19/14,
Changed sun's rotation to be based on time, not vice versa;
Split into multiple functions, for readability;
Various minor improvements;