Creating the day/night cycle – Distant Kingdoms

Wednesday, March 14th, 2018

Hello, I’m Laurene, Technical Artist at Orthrus studios. Today I will walk you through the development of the day/night cycle and the sky for Distant Kingdoms.
For this, I used the Unity engine and a plugin called ShaderForge. It allows artists to create shaders with a visual node-based system rather than pure scripting.

I love working on shaders and FXs for video games. Especially because it’s not all about drawing, but you also have to understand and use a few mathematical principles.

I will try to explain some of the steps I took to get the current result, but keep in mind, the project is young, and all of this needs some polish and will probably change.

The clouds in Distant Kingdoms might seem pretty irrelevant, as they are only visible in certain angles, but their shadows are present on the whole map. We wanted to find elements that would add depth and life to the game. Environmental effects are perfect for this since they are generally spread all over a zone and not too distracting for the player.

Because it would be a big effect, I decided to use procedurally-generated noises to create textures that would have a constant sharp definition, and whose values I could change easily. I linked a node to make them pan and move slowly into the sky.

The next step was for them to have their shapes changing. The goal was to mix the two noises and depending on if their values were higher or lower than a given step, they would become transparent or opaque.

In the first version of the clouds, they were in 3D. That allowed us to add multiple layers of planes on top of each other. The higher the plane, the smaller the cloud would be, until it eventually shrinks entirely.

Later, I decided to take off this system to apply the cloud on a curved mesh, to limit the fact that we could see their borders a lot, as it was bothering me. On the occasion, I added a gradient on the borders for them to disappear progressively.

The cloud’s shader is unlit – which means that it is not affected by the different lighting variations and doesn’t have roughness or metallic values. It is only affected to a certain percentage by the ambient lighting and main lights.


A skybox that would change depending on the time of the day became necessary. The sun’s orientation is the key to get which “time” it is in the game.

First, we create a dot where our sun is in the sky, with a few options to modify the size and blurriness. Using the world position, I then determine which values should be at the horizon or the top of the sky. I assign different colour to them and use a lerp to go between them progressively, from day to night.

A lerp is a function that has three inputs: two values that will be blended together and a third value that will be determining how those values will be blended. In this case if the sun is directed to the ground the day value will be used, when the sun is facing the sky, the night value will be used.

We then added stars that would show up only during night time. Finally, I added an option for the clouds to change colour during the night – rather than making it affected by the scene lighting – just because a solid colour modified directly in the material made it easier to control the look of our sky.


Here you can see my full shaders with all of their nodes:







Links that helped me a lot:

Procedural noise

Skybox reference 01

Skybox reference 02