In this lesson, you will learn how to create reactive materials that procedurally simulate environmental accumulation, such as snow or moss, using world-space orientation data.
Leveraging World-Space Normals
The secret to "reactive" environmental materials lies in determining which surfaces face "up" relative to the world. We can achieve this by using the World Normal node in the Material Graph. By taking the Dot Product of the World Normal and a Constant3Vector (0,0,1 for the Z-axis/Up), we get a mask value. Surfaces facing directly upward return 1, while vertical surfaces return 0.
Masking the Accumulation
To create a snow effect, we use this mask to blend between your base material and a snow material using a Lerp node. However, a simple dot product creates a hard transition. To make it more natural, we pipe the result through a Power or SmoothStep node to control the "clumping" of the snow.
// Conceptual logic inside a Material Function
float3 WorldUp = float3(0, 0, 1);
float DotResult = dot(WorldNormal, WorldUp);
float Mask = saturate(DotResult * SnowIntensity - SnowThreshold);
return lerp(BaseColor, SnowColor, Mask);
Adding Environmental Triggers
To make this dynamic, you shouldn't hardcode these values. Instead, use a Dynamic Material Instance to pass a "Global Weather Parameter" from a Blueprint. By creating a Scalar Parameter named SnowAmount, you can adjust the SnowThreshold in real-time. As the game time of day progresses or a storm begins, your Blueprint updates this parameter, causing the snow to "grow" across the environment dynamically.
For added realism, combine this world-space mask with a WorldPosition based noise texture. By using WorldPosition as the UV input for a noise function (like Perlin or Voronoi), you break up the uniform coverage, ensuring that snow settles in crevices and patches rather than forming a perfect, unnatural layer across every flat surface.
Key Takeaway: By calculating the Dot Product of the World Normal and the Up-Vector, you create a dynamic mask that allows environmental effects like snow or moss to accumulate procedurally based on surface orientation.