an in-game screenshot of a landscape, with big parts of the image being covered by the sky

Reaching for the stars ✨

Let’s create a procedural skybox shader with Unity’s Shader Graph!

Why do I need a procedural skybox?

Colouring the sky 🌈

a real world image of a sky above the sea
Photo by Luc Dobigeon on Unsplash

Unwrapping the skybox

a shader graph node setup, sampling a texture
Yeah, that’s not optimal. The texture is getting stretched everywhere!
a node setup that calculates skybox UVs
The complete node setup to calculate our UVs.
a correctly unwrapped skybox
The texture now wraps around once, and the stretch along the top is way less noticeable.
a node setup that interpolates two colours
Lerping Color

Adding sparkles: Stars

the Voronoi node in Unity’s Shader Graph
The Voronoi node.
the combined graph so far
This is where we are at now!
the skybox in game, stars on a gradient sky behind a landscape of trees
That’s a pretty sky!

The big pale moon (or sun?)

Shader.SetGlobalVector(“_SunDirection”, transform.forward);
a screenshot depicting the property setup for the sun direction
The proper property setup.
a big, round moon above the same landscape
the node setup for the sun
The node setup for the sun!
another red moon overlapping our first moon, creating a crescent shape
Just like this 👆
an animation of changing moon parameters, inner and outer size
Tweaking the values. Reducing the mask size to 0 will leave you with a full moon/sun.
the complete moon node setup

Clouds

a seamless Perlin Noise texture
Just save this texture!
the node setup to generate a cloud texture
Man, that’s a big graph!
the same sky as before, covered in clouds
But now there are clouds everywhere!
the cloud setup, now with another branch calculating a mask
Extending the setup with a mask.
an animation of changing cloud parameters like size and falloff
Adjusting the cloud height and edge.

Hiding the horizon: Fog!

a small node setup to incorporate fog
This is a small one, phew!
the same sky as before, but smoothly blended into the fog
See? No more hard edges!
the complete node setup

--

--

indie game developer ✨ they/he

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store