Dynamic Sky - "World Sun"

After using Physical Starlight & Atmosphere, by Martin Upitis, I attempted to put together what I hope becomes a fraction of what his addon will be in the future. My goal is to eventually make a versatile dynamic sky that’s between semi realistic and a toon sky.

What I have so far is a node group called “WorldSun” that contains controls for sky(Sky Height, strength, palette), sun(position, size and color), “sunshine”/“rays” and a basic start for stars.

One main factor in making this node group was that I was testing UPBGE EEVEE along with using Physical Starlight but had some issue which only allowed the sun lamp(the one added by the addon) to only show up on one scene when switching levels or scenes in viewport. I also wanted more control of the sun’s(lamp) color and it’s own rotation so I made it possible by having a “Sun Controller” input, which is meant for a texture coordinate, and a color value that affects the sun’s color and brightness. For the sun to appear in the sky a texture coordinate set to object and an object need to be selected. In the picture below I set the object to a sun lamp, therefore the sun’s location will be determined by the rotation of that lamp. One thing to note is that the mapping node is optional(doesn’t need to use an object) and the object set to be the controller must remain at 0,0,0 and should not be scaled.

The “WorldSun” node contains a palette which is used in the picture above, but I didn’t want to have to go into the node group to change it every time so there is an input “Custom Palette” for just that. To input a palette, connect the color output of a color ramp to “Custom Palette”, then connect the “Sky Color Math” to the fac of the color ramp (ignore the dependency loop) and finally move the “Palette Mixer” slider to change/mix the palettes.
The following are some of the palettes I added.

Namek Palette

Unity Palette

Depending on the type of project one might be working on, the sky and the way it looks can be an important aspect so changing the interpolation mode might help.

The node group is made up of a few other node groups and most inputs are labeled so it shouldn’t be too difficult to get around for people who have some experience with nodes and wish to make their own changes. While creating this post I came up with a list of several new things to add and ways to approach them but they will be limited to my knowledge and how well they can be included without affecting performance too much.

I did leave out directions to some of the inputs but I hope they’re self explanatory or at least fun to figure out. The animation from the video and palettes from the pictures are included in the blend file and can be tweaked and used for whatever purpose.
World Sun.blend (994.3 KB)


Pretty cool. I have lots of files laying around for toony sky stuff – faking lens flare, exaggerating the sunrise, moon cycles, that kind of stuff. theyre for old upbge though so some redoing of materials would be in order to get any of it to eevee.

if you like any of it maybe i can help develop some. im too busy these days but i can at least do some porting and file sharing.

1 Like

Did you use python to animate the sun position and is it what controls the sky color?
Some of the changes I plan to make include the sun affecting the sky height and it’s brightness through the sun’s rotation. I want to add moon parameters like scale, brightness and ways in which the sun position affects it, as well as a mixer for a toon moon like yours but be able to change it’s phases independently of the sun.

python, yes. theres a worldtime object, basically a timer with a calendar and leap years, always ticking. sky color goes through a list of color vectors depending on which time it is and interpolates between current color and next one as hours pass.

then the sun (the display mesh as well as the actual lamp) are parented to an empty which sets its orientation according to the exact time of day. similar thing with the moons phases and orbit, except it moves much more slowly; about five or six days between each phase and a month or so for a full orbital cycle.

more or less the system relies on time ranges for the most part,
ie if period start < current time < period end, do this and that.

for instance, the sun goes up in scale as it nears the horizon and nightime draws near. i dont actually check for the suns rotation, as i set it so that at a given hour itd be guaranteed to be at a certain place.

lastly, i didnt add this one last feature but its also possible. have the time ranges start and end values vary according to seasons, weather or what have you. same thing could be done for sky/lamp colors as well. a whole lot of fun stuff to simulate.

WorldSun v.2

With this version :
Sun Color Influence – Will mix the sun’s color to the sky
Sun Inf. Type ----------- 0 uses (MixRGB) Multiply and 1 uses (MixRGB) Color for the above
Sun Size ---------------- Increasing the sun size adds strength to “World Strength”
Sun Color --------------- Color adds to “World Strength” and black will make the sun white
Sun Strength ----------- Adds strength to the sun and to “World Strength”
Star Color --------------- Stars are now an image
Node Groups are hidden and only WorldSun v.2 should appear

This blend contains the node group WorldSun v.2 with the animations from the video without the models
WorldSun v.2.blend (4.3 MB)


Progress after recent release:

Horizon Position (separate from “Sky height”)





The moon will work similar to the sun with the addition of parameters for the shadow cast on to it

There’s tweaking and clean up to be made before releasing this version, but I would first like to know if anyone has encountered issues I should work on. So far the only one I found was multiple gradients showing up on the sun(pictured below) and have since fixed it. This issue only showed on lower spec PC’s that I tested on. It didn’t show on my main computer (gt 1030), but was faint on a gt 940 and more visible on a PC using Intel HD Graphics 630.

…gradient as seen on the Intel HD Graphics 630


Anyone got a more realistic setup of this amazing node system? I can’t get it to look quite realistic.

Do you have an example of what you’re trying to mimic?

Went off-track while working on the moon and ended up adding clouds. I’m not planning on making them procedural(for performance) but it can be added later. Ironically, the cloud texture was generated in Blender using a noise node and rendered as a black and white HDRI. What I intend to do is create multiple noise textures that can be mixed together for different results and a slider to switch between those textures. Each texture will be rendered using a different scale, detail, roughness, and distortion. The only concern I have for this method is that the file will get to big but I can also just exclude images and include inputs to let users add their own.

The images below are HDRI’s rendered in Cycles so the colors won’t always match EEVEE’s.


WorldSun v.3

—Shader Input—
Horizon Position ---------------- moves horizon along the z-axis
Star Color ------------------------ new image (might add an input for custom image)
Moon Controller ---------------- works exactly the same as Sun Controller
Moon Size ----------------------- works exactly the same as Sun Size but has different presets
Moon Color ---------------------- changes the Moon’s color and stength
Moon Shadow Visibility ------- when visible the moon is masked by a circle to show the sky
Moon Shadow Scale ---------- Moon Shadow is scaled through this slider and with Moon Size
Moon Shadow y-pos.---------- shifts Moon Shadow left or right (depends on Moon rotation)
Moon Shadow z-pos.---------- shifts Moon Shadow up or down (depends on Moon rotation)
Cloud Amount ------------------ works as a color ramp to increase or decrease the visible clouds from the texture in Cloud img - 1
Cloud img - 1 ------------------- texture used for clouds
Cloud img - 2 ------------------- texture used for cloud colors (works best if input comes from a different node output than Cloud img - 1 but can be the same texture)
Cloud Colors -------------------- needs a color ramp and Cloud img - 2 must have an input to have results
Cloud Color Spreader -------- modifies Cloud Colors if a color ramp is used
Cloud Color Shift - x ---------- shifts Cloud img - 2 in two directions (works if Cloud img - 2 input comes from a different node than Cloud img - 1)
Cloud Color Shift - y ---------- shifts Cloud img - 2 in two other directions (works if Cloud img - 2 input comes from a different node than Cloud img - 1)
Cloud + Sky Color ------------- blends the sky colors onto the clouds
Cloud Color Invert ------------- invert the color ramp used in Cloud Colors
Cloud Height -------------------- scales clouds on the z-axis
Cloud Rotation ----------------- works by changing x, y and z values (doesn’t work well if using an object for coordinates)

—Shader Outputs—
to Cloud Color ----------------- connect this output to the color ramp used in Cloud Colors (needed for Cloud Color Shift, Spreader and Invert to work)
to Cloud Color img - 1 ------- connect to vector input for Cloud Color img - 1 (needed for rotations)
to Cloud Color img - 2 ------- connect to vector input for Cloud Color img - 1 (needed for rotations and shifts)

Notes: (new and old)

  • This was a big update and a lot of settings were tweaked so not all values will turn out the same as previous versions
  • Sun Size, Sun Color and Sun Strength values affect the cloud’s brightness
  • To make a night scene Sun Size, Sun Color and Sun Strength values must be lowered
  • Sun Size can go over 100
  • World Strength only increases strength of the sky colors and can go above 1
  • World Strength value can be negative to make the sky darker but doesn’t look good if Sun or Moon Strength are high and can produce flickering
  • Moon and Shadow scaling needs more work
  • Moon Shadow will also mask the Sun and Stars from showing behind the moon
  • For objects used as Sun or Moon Controller only rotate X and Z and lock all other transforms
  • Using a lower Cloud Height becomes visible if Horizon Position is also low
  • Procedural nodes can be used for Cloud textures but will impact performance
  • WorldSun shader can be used on an object (ex. a big sphere) to be used as background and the scene be lit through another source
  • There’s a group called Value Mixer that’s used a lot within this version. It works like MixRGB but for values.

The blend file size is too high for upload so I gathered all previous versions and posted them on this gumroad page : https://gum.co/ifUne

1 Like

Thats fantastic, the effect is beautiful… Thanks a lot for this.

1 Like