Create a gradient sky
A gradient sky is a simple representation of the sky, where the High Definition Render Pipeline (HDRP) interpolates between the following three colors:
- Top
- Middle
- Bottom
You can alter these values at runtime.
Using Gradient Sky
Gradient Sky uses the Volume framework, so to enable and modify Gradient Sky properties, you must add a Gradient Sky override to a Volume in your Scene. To add Gradient Sky to a Volume:
- In the Scene or Hierarchy view, select a GameObject that contains a Volume component to view it in the Inspector.
- In the Inspector, go to Add Override > Sky and select on Gradient Sky.
After you add a Gradient Sky override, you must set the Volume to use Gradient Sky. The Visual Environment override controls which type of sky the Volume uses. To set the Volume to use Gradient Sky:
- In the Visual Environment override, go to Sky > Sky Type
- Set Sky Type to Gradient Sky.
HDRP now renders a Gradient Sky for any Camera this Volume affects.
Refer to the Gradient Sky Volume Override Reference for more information.
API
To access and control this override at runtime, use the Volume scripting API. Because of how the Volume system works, you edit properties in a different way to standard Unity components. There are also other nuances to be aware of too, such as each property has an overrideState. This indicates to the Volume system whether to use the property value you set, or use the default value stored in the Volume Profile. For information on how to use the API correctly, see Volume scripting API.