ProceduralSkyMaterial in Godot – Complete Guide

Creating immersive environments is a fundamental aspect of game development, and the atmosphere often starts with the sky. Whether you’re crafting an expansive outdoor scene or just looking for a dynamic backdrop for your game, understanding how to create a sky that can adapt to the mood of your world is crucial. Godot 4’s ProceduralSkyMaterial class offers a powerful way to achieve this without needing complex art assets, making it accessible to developers of all skill levels.

What is ProceduralSkyMaterial?

ProceduralSkyMaterial is a class in Godot 4 that allows developers to generate dynamic skies through procedural generation. This means you can create varied skydomes with custom parameters for elements like the sun, sky, and ground, without manually designing each detail.

What is it for?

ProceduralSkyMaterial is designed to quickly develop effective sky backgrounds with simple user-defined parameters. It’s especially useful when you need a sky that changes in real-time or reacts to game events, such as time of day transitions or weather changes, enhancing the gaming experience with minimal performance impact.

Why should I learn it?

Understanding how to use the ProceduralSkyMaterial not only broadens your skillset in creating dynamic game environments, but it also allows you to add depth and immersion to your game worlds with ease. Learning to control skies procedurally is an invaluable asset for any game developer looking to make their games visually compelling and dynamic.

CTA Small Image

Setting Up the ProceduralSkyMaterial

To begin, we’ll create a new ProceduralSkyMaterial instance and attach it to our skydome or Sky resource in a WorldEnvironment node. This is the foundation from which we’ll build our dynamic sky.

var sky_material =
var sky =
sky.sky_material = sky_material
$ = sky

Once the sky material is set up, we can start tweaking its properties.

Configuring the Sun

The sun is a pivotal part of your sky’s appearance. We can adjust position, color, and even how it interacts with the atmosphere using the ProceduralSkyMaterial’s properties.

# Set the sun's position
sky_material.sun_latitude = 45.0
sky_material.sun_longitude = -30.0

# Define the sun's color
sky_material.sun_color = Color(1.0, 0.8, 0.6)

# Adjust the sun's energy and how it affects the sky's color
sky_material.sun_energy = 2.0

These simple adjustments let you align the sun’s position with the desired time of day or even simulate different seasons.

Customizing the Sky Appearance

Besides the sun, the sky itself is a canvas for your creativity. We have multiple parameters to adjust the colors of the sky’s top, horizon, and ground, as well as how the light scatters.

# Top sky color, usually a deeper blue
sky_material.sky_top_color = Color(0.0, 0.3, 0.8)

# Horizon color, where the sky meets the earth
sky_material.sky_horizon_color = Color(0.1, 0.22, 0.5)

# Ground color, representing the earth's surface from a distance
sky_material.ground_bottom_color = Color(0.2, 0.1, 0.0)

Experimentation will yield the best results, as varying these colors can simulate the effect of different times of day or atmospheric conditions.

Simulating Atmospheric Effects

For added realism, you can simulate the scattering of light in the atmosphere. ProceduralSkyMaterial offers properties to control how the sky and sun appear under various atmospheric conditions.

# Adjust the strength of the light scattering
sky_material.sky_energy = 0.9

# Modify the atmosphere's thickness which affects sunlight
sky_material.atmosphere_thickness = 1.1

# Control how light spreads horizontally in the sky
sky_material.atmosphere_horizon_color = Color(1.0, 0.5, 0.3)

By playing with these settings, you can achieve a range of effects, from clear blue skies to golden sunsets or even moody, overcast days. It’s a game of balance that requires visual feedback, so keep testing till you find the perfect atmosphere.

Creating Time of Day Transitions

Dynamic skyboxes will often require transitions between different times of day. Below are some examples of how you might interpolate between different ProceduralSkyMaterial properties over time to simulate a day/night cycle.

# Calculate the desired sun position based on time
var time_of_day = 0.5 # Midday; 0.0 = sunrise, 1.0 = sunset
sky_material.sun_latitude = lerp(15.0, -15.0, time_of_day)

# Interpolate colors based on the same time value
sky_material.sky_top_color = Color(0.0, 0.3, 0.8).linear_interpolate(Color(0.0, 0.0, 0.2), time_of_day)
sky_material.sky_horizon_color = Color(0.1, 0.22, 0.5).linear_interpolate(Color(0.1, 0.1, 0.2), time_of_day)

By updating these properties gradually over time, perhaps through a coroutine or a timestep in your main game loop, you can showcase beautiful transitions that immerse players in your game’s world.

Adjustments to your procedural sky can extend beyond sun position and sky color. We can also configure elements like sky curvature and stars for night-time skies. Here is how you can enhance your sky with these additional features:

# Configure the sky curvature to give a more realistic, round appearance to the sky dome
sky_material.sky_curve = 0.8
sky_material.sky_curve_near_scale = 0.5

# If you're creating a night sky, you might want to add stars
sky_material.stars_enabled = true
sky_material.star_density = 0.7 # Adjust the density of stars

# Because stars come with different colors, we randomize their hue
sky_material.stars_color = Color(1.0, rand_range(0.8, 1.0), rand_range(0.8, 1.0))

Controlling cloud appearance is also essential for certain types of games or scenes. With ProceduralSkyMaterial, you can introduce clouds and tweak their characteristics without hand-painting their shapes and movements.

# Enable and adjust settings for clouds
sky_material.clouds_enabled = true
sky_material.cloud_height = 0.05
sky_material.cloud_opacity = 0.8  # Vary to make clouds more or less transparent

# Fine-tune the speed and direction of cloud movement
sky_material.cloud_speed = 0.03
sky_material.cloud_direction = Vector2(1.0, 0.0)

For games that have weather systems, or for developers wanting to showcase different weather phenomena, adding fog to your procedural sky can be incredibly effective:

# Adjust fog parameters for a misty morning or a foggy scene
sky_material.fog_sun_amount = 0.9  # Sun's contribution to the fog
sky_material.fog_depth_begin = 500.0  # Distance at which fog starts to be visible
sky_material.fog_depth_end = 1000.0  # Distance at which fog is fully opaque

# Fog color can be changed to match the environment and time
sky_material.fog_color = Color(0.8, 0.7, 0.65)

One of the most dynamic features you can manipulate is changing the sky’s appearance based on the player’s altitude:

# Adjust sky properties based on altitude
var player_altitude = $Player.global_transform.origin.y

# Altitudes above a certain threshold can have less atmosphere, resulting in a deeper blue sky
if player_altitude > 1000.0:
    sky_material.atmosphere_thickness = max(sky_material.atmosphere_thickness - player_altitude * 0.001, 0.9)

This simple check allows us to create a natural transition for players as they explore different elevations in the game world, making mountain tops and flying sequences much more realistic.

Each piece of code we write and each parameter we set can deeply affect the atmosphere and player immersion. Take the time to understand each setting’s impact and don’t be afraid to experiment. Procedural generation tools, such as Godot 4’s ProceduralSkyMaterial, are there to facilitate your creativity, enabling you to create compelling and engaging worlds with efficiency and precision.

As we delve into these features, remember—not only are we teaching you critical development skills, but we’re also encouraging you to think about how your technical choices shape the gaming experience. At Zenva, we believe in blending learning with creativity, providing you with knowledge that translates into fun, interactive, and memorable experiences for your future players.

Now, we’ll dive into the dynamic range of the sky and how it reacts to the lighting within the game. The ProceduralSkyMaterial includes adjustable parameters for exposure and the baked-in glow that can mimic real-world light dynamics.

# Adjust the overall exposure of the sky to simulate brightness or darkness
sky_material.exposure = 1.2

# Configure the tone mapping to control how high dynamic range colors are mapped to the screen
sky_material.tonemap_mode = ProceduralSkyMaterial.TONE_MAPPER_REINHARD

# Adjust the glow intensity for a subtle brightening effect at the horizon
sky_material.glow = 0.3

The realism doesn’t stop there; the procedural sky can also reflect the varying nature of the sun throughout the day and even simulate solar phenomena like solar halos.

# Solar halo effect to give the sun a more realistic and dynamic feel
sky_material.solar_halo_size = 0.2
sky_material.solar_halo_strength = 3.0

Adding intermittent effects for simulation of passing clouds can be achieved through animation or shader logic applied to the sky material. The key is to modify certain properties over time:

# Animating the cloud opacity to simulate passing clouds
sky_material.cloud_opacity = 0.8 # Start with a base opacity
var tween =

func animate_clouds():
    tween.interpolate_property(sky_material, "cloud_opacity",
                               0.8, 0.5, 3,
                               Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
    tween.interpolate_property(sky_material, "cloud_opacity",
                               0.5, 0.8, 3,
                               Tween.TRANS_LINEAR, Tween.EASE_IN_OUT, 3) # Start delayed

# Remember to add the Tween node to the scene and connect its signals

Furthermore, we can dynamically adjust parameters in reaction to in-game events, such as weather changes or environmental effects, by using function calls that respond to the game’s state:

# Function to update sky material properties for a rainy day
func set_rainy_weather():
    sky_material.sky_top_color = Color(0.2, 0.2, 0.3)
    sky_material.sky_horizon_color = Color(0.15, 0.15, 0.2)
    sky_material.cloud_opacity = 1.0
    sky_material.cloud_speed = 0.1

For those interested in celestial additions, Godot’s ProceduralSkyMaterial also provides ways to simulate a more vibrant night sky with the Milky Way or custom star patterns.

# Implement the Milky Way for a more realistic night sky texture
sky_material.milky_way_stars_texture = preload("res://textures/milky_way_stars.png")
sky_material.milky_way_stars_intensity = 1.2

Moon phases and transitions can add a beautiful and functional element to the night scene:

# Moon phase simulation
sky_material.moon_phase = 0.5 # Half moon
sky_material.moon_scale = 0.075 # Adjust the size of the moon
sky_material.moon_halo_strength = 4.0

# Update the moon phase dynamically, perhaps according to a calendar system
func update_moon_phase(phase):
    sky_material.moon_phase = phase

Working with the ProceduralSkyMaterial encourages a deeper understanding of the powerful impact that lighting and atmospherics have on player experience. These code snippets demonstrate the level of control we have over our environment and how we can evoke emotions and tell stories through the sky itself.

At Zenva, we aim to empower you with knowledge that not only expands your technical abilities but also inspires you to craft engaging player experiences. Remember, these techniques are just the beginning. As you become more versed in these tools, you’ll discover countless ways to express your vision and improve your games’ atmospheres.

Continuing Your Game Development Journey

The sky’s the limit when it comes to furthering your skills in game development, and embracing the dynamics of Godot 4’s ProceduralSkyMaterial is only the beginning. If you’ve enjoyed unlocking the potential of customizable skies and want to expand your development toolkit, our Godot Game Development Mini-Degree is the perfect next step in your journey.

This comprehensive collection of courses vastly extends your learning into all realms of Godot 4, from mastering the GDScript language to diving deep into 2D and 3D game mechanics. It’s structured to guide you from the basics to advanced concepts, enabling you to build actual games that can stand as portfolio pieces, all while ensuring flexible learning. Whether you are starting your game development career or looking to enhance your current skill set, this Mini-Degree is designed to be both accessible for newcomers and rich in content for seasoned developers.

And for those who wish to explore even broader horizons, our full range of Godot courses covers the ins and outs of the engine. With Zenva, you can progress from beginner to professional at your own pace, reinforcing your learning with live coding sessions, interactive quizzes, and lessons that resonate with real-world game development scenarios. Keep crafting, keep learning, and let us help you turn your passion into a thriving career.


In the vast universe of game development, mastering the ambiance of your skies with Godot 4’s ProceduralSkyMaterial can take your games from good to extraordinary. The skills you’ve glimpsed today are only a teaser for the full potential that awaits your curiosity and creativity. As we provide you with the powerful tools and in-depth knowledge through our Godot Game Development Mini-Degree, you’re not just learning—you’re becoming a part of an innovative community that’s shaping the future of gaming.

Let your journey continue with us at Zenva, where every course you take is a step towards bringing your most ambitious game ideas to life. Engage with the material, let your imagination reign supreme, and build worlds that resonate with players around the globe. Together, we can make that pixelated dream a playable reality.

Python Blog Image

FINAL DAYS: Unlock coding courses in Unity, Godot, Unreal, Python and more.