Pic 1: Time-lapse of a full cycle achieved in CRYENGINE
In this tutorial we will be going over the process of creating a day-night cycle using the Environment Editor inside CRYENGINE, which will serve as a good basis for most Earth like lighting scenarios. This will cover setting up a few different times of day as well as the transitions between them, while also staying within the boundaries of physically accurate lighting.
Before we get into the details please keep in mind that all of the parameters in the Environment Editor contribute to the final look of your level and they are all affecting each other. The influence of some of them only becomes apparent when certain conditions are met so creating a polished lighting scenario requires quite a lot of back and forward between different elements. This tutorial is not a step by step workflow, it’s aimed at giving you a better understanding of the system and the things you can achieve by controlling the parameters made available by it.
It is important to note that CRYENGINE uses two distinct fog models to create atmospheric effects. For high quality results we are using a voxel-based volumetric fog model designed to accurately interact with all entities in your level. Keep in mind that this has a noticeable impact on performance, so as an alternative for the lower end we provide the option to use regular fog. In a nutshell, Volumetric Fog allows lights, cubemaps, and shadow to interact with the global/local atmosphere, whereas regular fog does not. We will be covering both of these options in this tutorial.
As mentioned in the beginning it is important to stay within physically accurate illuminance values when setting up any lighting scenario in order to get the most out of our PBS pipeline, so depending on the result you are trying to achieve, some research might be in order as to what your illuminance values should be. At the same time getting the desired look for your environment is always the highest priority so it takes some fine tuning to achieve something that looks good but still follows real world values.
To open the Environment Editor go to Tools on the main toolbar and select the Environment Editor from the list. The layout of this tool incorporates a number of different elements. On the left side we have the Presets list, under it there are the Sun orientation/angle settings and next to these there’s the list of customizable parameters. On the right side you can find the curve editing tools, the timeline at the top, a visual representation of the selected property under it and at the bottom we have the Start/Current/End time values as well as controls for playing the cycle.
Pic 2: Environment Editor Layout
To change the time of day simply drag the triangle in the timeline to either side. You cannot go beyond the 0 and 1 values since they represent a full 24 hour cycle.
The Environment Editor contains a wide number of advanced parameters that would allow you to fully customize the lighting in your level as well as the appearance of the sky. These parameters are split into logical groups that each control different aspects of your environment.
The curve editor is used to control the transition between different values of the same parameter throughout the day. It will automatically create a key for you at the current time once you change the value.
We won’t be going over all of these parameters as some of them don’t require any changes for the generic earth like scenario we’re aiming for. We will however cover the sections that we are changing to get a better idea of what they control. We will also go through the process of creating smooth transitions as the time of day changes by using the curve editor.
In this example our goal is to achieve a generic day-night cycle at 45° latitude.
We will begin by opening up our example level day-night_cycle.cry. As you probably noticed the scene is already set up with the cycle, to start from scratch we will have to create a new environment preset. To do that right click on the left side under Presets/File view - > Add -> New and save it as day-night_cycle.xml. To open up an existing preset you will have to select Add -> Existing. Presets are saved in the \gamesdk\libs\environmentpresets folder.
Next we need to set up the Sun direction and the latitude. These values are located under the preset list on the left side of the editor. Set the Sun Direction to 180° so it rises in front of the camera. For the latitude we have to change the NortPole..Equator..Southpole value to 45. These two values are not stored in the environment preset file so you can use the same preset with different settings for orientation and latitude.
The first thing that we need to do before we start setting up our cycle is change the Film curve whitepoint to 4 ( default is 1 ). This can be found under the HDR group in the Environment Editor. We will also be using the new and improved Eye Adaptation mode, to do this open up the console and simply type in r_HDREyeAdaptationMode 1. These 2 values dramatically change the sensitivity to light so they need to be set up properly before changing any of the other parameters.
Now we are ready to start creating our day-night cycle.