# First steps to making daytime cycle material shader (animated)

**URL:** <https://forums.unrealengine.com/t/first-steps-to-making-daytime-cycle-material-shader-animated/81713>\
**Category:** UDK Content Creation and Design\
**Tags:** unreal-engine\
**Created:** [January 1, 2017, 2:27pm UTC](https://forums.unrealengine.com/t/first-steps-to-making-daytime-cycle-material-shader-animated/81713 "2017-01-01T14:27:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathaniel3W](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nathaniel3W](https://forums.unrealengine.com/u/Nathaniel3W)\
**Post date:** [January 1, 2017, 2:27pm UTC](https://forums.unrealengine.com/t/first-steps-to-making-daytime-cycle-material-shader-animated/81713/1 "2017-01-01T14:27:02Z")

</div>

[![](http://himekosutori.com/wp-content/uploads/2017/01/Time-of-day-optimized2.gif) ](http://himekosutori.com/wp-content/uploads/2017/01/Time-of-day-optimized2.gif)

I’m getting started on the day cycle in my game. I figured the easiest way without resorting to performance-killing dynamic lights would be to make an unlit material that had a bunch of parameters for controlling the light. This is what I came up with.

Anyone interested in making your own, this is what I started off with:

 ![Time-of-day-template.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/f/3/f38f108073bdbb634010d4114042fb74ff1e80a8.jpeg)

Basically I take the diffuse and normal textures from a regular material and bring them over. I make an unlit material and simulate lighting with the parameters shown. From there, I replaced those few parameters with several others: light, shadow, and highlight colors, each times four in order to have different color schemes for sunrise, daylight, sunset, and night. Then I add another parameter for time of day, and use that to lerp between colors. Next I need to add something to turn the light.

---

<div class="post-metadata">

**Author:** ![Nathaniel3W](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nathaniel3W](https://forums.unrealengine.com/u/Nathaniel3W)\
**Post date:** [January 2, 2017, 12:37pm UTC](https://forums.unrealengine.com/t/first-steps-to-making-daytime-cycle-material-shader-animated/81713/3 "2017-01-02T12:37:25Z")

</div>

It seems to be working pretty well so far. Because it’s unlit, it runs at a svelt 47 instructions. And that’s including all of the layer switching and 3D texture projection.

[![](http://himekosutori.com/wp-content/uploads/2017/01/HS_LandscapeDayCycleTest_optimized.gif) ](http://himekosutori.com/wp-content/uploads/2017/01/HS_LandscapeDayCycleTest_optimized.gif)

Getting all of the landscape’s normals figured out was kind of a pain, but I think I finally have it right.

---

<div class="post-metadata">

**Author:** ![CobaltUDK](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cobaltudk/32/1194497_2.png) [@CobaltUDK](https://forums.unrealengine.com/u/CobaltUDK)\
**Post date:** [January 4, 2017, 4:21pm UTC](https://forums.unrealengine.com/t/first-steps-to-making-daytime-cycle-material-shader-animated/81713/5 "2017-01-04T16:21:43Z")

</div>

Looks good, but the lack of shadows… why don’t use dynamic light? With a proper cascade configuration the performance are not too bad with the modern computers.

---

<div class="post-metadata">

**Author:** ![Nathaniel3W](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nathaniel3W](https://forums.unrealengine.com/u/Nathaniel3W)\
**Post date:** [January 4, 2017, 5:00pm UTC](https://forums.unrealengine.com/t/first-steps-to-making-daytime-cycle-material-shader-animated/81713/6 "2017-01-04T17:00:28Z")

</div>

The last time I used dynamic lights was years ago and I was running a tiny weak Radeon. Maybe I should give dynamic lighting another try. I was hoping to approximate shadows with AO, but we’ll see. I’ll give dynamic lighting a try and see what happens.
