The code for this and explaination is available here: https://medium.com/@shahriyarshahrabi/day-night-cycle-using-lut-in-fragment-shader-of-materials-80edaf26f655