Scripting Support (C#)

advanced scripting

Global Snow (URP) · Scripting Support (C#)

Control Global Snow at runtime using the GlobalSnowEffect namespace. The snow effect is accessible via the singleton GlobalSnow.instance.

using GlobalSnowEffect;

GlobalSnow snow = GlobalSnow.instance;
snow.snowAmount = 0.8f;
snow.snowTint = Color.white;
snow.UpdateMaterialProperties();

GlobalSnow

MonoBehavior that manages snow coverage, particles, terrain marks, footprints, frost, and coverage masking. Access via GlobalSnow.instance.

General

static GlobalSnow instance read-only

Singleton reference to the active GlobalSnow component.

Camera snowCamera read-only

The internal camera used for zenithal depth coverage.

GlobalSnowProfile profile

Gets or sets a profile. Setting applies all profile settings to the snow component.

GameObject sun

Reference to the directional light used for snow lighting calculations.

bool showSnowInSceneView

Renders snow in the Scene View for live preview without Play mode.

bool addSnowToGrass

When enabled, snow is applied to terrain grass objects.

Snow Appearance

float snowAmount

Overall snow intensity. Range 0 (none) to 2 (maximum). Default 1.

Color snowTint

Tint color applied to the snow surface.

SnowQuality snowQuality

Snow detail level: FlatShading, NormalMapping, or ReliefMapping.

float smoothness

Snow surface glossiness. Range 0-1, default 0.9.

float snowNormalsStrength

Normal map strength. Range 0-2.

float reliefAmount

Relief parallax intensity. Range 0.05-0.3, default 0.3.

float noiseTexScale

Scale of the noise texture. Default 0.1.

float glitterStrength

Sparkle/glitter effect intensity. Default 0.75.

bool occlusion

Enables ambient occlusion on snow. Default true.

float occlusionIntensity

Snow ambient occlusion strength. Range 0.01-5, default 1.5.

float maxExposure

Maximum snow brightness. Range 0-2, default 0.85.

float subsurfaceScattering

Subsurface scattering intensity. Range 0-1, default 0.25.

Color subsurfaceScatteringColor

Tint color for the subsurface scattering effect.

bool preserveGI

Retains existing global illumination on snow-covered surfaces.

float minimumGIAmbient

Minimum ambient GI level when preserveGI is enabled. Range 0-1, default 0.2.

Altitude & Coverage

float minimumAltitude

Minimum world-space altitude where snow appears. Default -10.

float minimumAltitudeVegetationOffset

Additional altitude offset for vegetation snow coverage.

float altitudeScatter

Randomness in the altitude snow boundary. Range 0-250, default 20.

float altitudeBlending

Altitude transition smoothing. Range 0-500, default 25.

bool useZenithalCoverage

Enables the top-down depth coverage pass. Default true.

int coverageResolution

Coverage depth texture resolution multiplier. Range 1-4, default 1.

int coverageExtension

Coverage capture area size. Range 1-4, default 1.

float groundCoverage

Ground-level snow amount. Range 0-0.5.

float groundCoverageRandomization

Randomization of ground coverage. Range 0-2, default 0.5.

float grassCoverage

Snow coverage on terrain grass. Range 0-1, default 0.75.

float billboardCoverage

Snow coverage on tree billboards. Range 0-2, default 1.4.

SnowCoverageUpdateMethod coverageUpdateMethod

When the zenithal coverage is recomputed: EveryFrame, Discrete (on camera movement), Manual (call UpdateSnowCoverage()), or Disabled. Default Discrete.

bool showCoverageGizmo

Shows the coverage capture area boundary in the Scene View.

bool coverageDepthDebug

Displays the zenithal depth buffer on screen for debugging coverage issues.

Slope

float slopeThreshold

Slope angle threshold for snow removal. Range 0-1, default 0.7.

float slopeSharpness

Sharpness of slope-based snow removal. Range 0-1, default 0.5.

float slopeNoise

Noise on slope-based snow edges. Range 0-1, default 0.5.

Coverage Mask

bool coverageMask

Enables the coverage mask system.

Texture2D coverageMaskTexture

Coverage mask texture. White = snow, black = no snow.

Vector3 coverageMaskWorldSize

World-space size of the mask coverage area.

Vector3 coverageMaskWorldCenter

World-space center of the mask area.

bool coverageMaskFillOutside

Fill areas outside the mask with snow. Default true.

Snowfall

bool snowfall

Enables snowfall particles. Default true.

float snowfallIntensity

Snowfall particle density. Range 0.001-1, default 0.1.

float snowfallSpeed

Falling speed of snowflakes. Default 1.

float snowfallWind

Wind effect on snowflakes. Range 0-2.

float snowfallDistance

Max render distance for snowfall. Range 10-200, default 100.

bool snowfallUseIllumination

Snowfall particles affected by scene lighting.

float snowdustIntensity

Snow dust particle intensity. Range 0-1. Set to 0 to disable.

float snowdustVerticalOffset

Vertical offset for snow dust emitter. Range 0-2, default 0.5.

Camera Frost

bool cameraFrost

Enables camera frost overlay. Default true.

float cameraFrostIntensity

Frost intensity. Range 0.001-1.5, default 0.35.

float cameraFrostSpread

Frost spread from screen edges. Range 1-5, default 1.2.

float cameraFrostDistortion

Frost refraction distortion. Range 0-1, default 0.25.

Color cameraFrostTintColor

Tint color for the frost overlay.

Terrain Marks

bool terrainMarks

Enables terrain mark deformation trails.

int terrainMarksDuration

Seconds before marks fade. Range 1-240, default 180.

float terrainMarksDefaultSize

Default mark stamp size. Range 0-1, default 0.25.

float terrainMarksViewDistance

Max visibility distance for marks. Range 0-1024, default 200.

float terrainMarksRoofMinDistance

Min distance from overhead geometry to allow marks. Default 0.5.

bool terrainMarksAutoFPS

Auto-generate marks from character controller movement.

float terrainMarksStepMaxDistance

Max distance between consecutive auto marks. Default 20.

float terrainMarksRotationThreshold

Minimum rotation change to trigger a new mark. Default 3.

DecalTextureResolution terrainMarksTextureSize

Internal decal texture resolution for terrain marks: _512, _1024, _2048, _4096, or _8192. Default _2048.

Footprints

bool footprints

Enables footprint stamps.

Texture2D footprintsTexture

Custom footprint texture. Uses default shape if null.

bool footprintsAutoFPS

Auto-generate footprints from character movement.

int footprintsDuration

Seconds before footprints fade. Range 1-240, default 60.

float footprintsScale

Footprint size multiplier. Range 0.04-1, default 1.

float footprintsObscurance

Darkening intensity. Range 0.05-0.5, default 0.1.

GroundCheck groundCheck

Detection method for automatic footprints and terrain marks: None, CharacterController, or RayCast.

CharacterController characterController

Reference to the character controller for ground detection. Auto-detected if not set.

float groundDistance

Maximum raycast distance for ground detection when using RayCast mode. Default 1.

Layer & Exclusion

LayerMask layerMask

Controls which objects can receive snow based on their layer. Objects on excluded layers are rendered into the exclusion buffer and will not show snow. Objects on Layer 0 (Default) are never excluded by this mask. Default: all layers.

LayerMask zenithalMask

Controls which layers participate in the top-down depth pass for occlusion. Objects on excluded layers will not block snow on surfaces below them. Default: all layers.

int defaultExclusionLayer

Layer index for exclusion rendering. Default 27.

float exclusionBias

Depth bias for exclusion mask. Default 0.99.

bool exclusionDoubleSided

Double-sided exclusion rendering for complex geometry.

float exclusionDefaultCutOff

Alpha cutoff for excluded transparent objects. Range 0-1.

bool exclusionUseFastMaskShader

Use optimized mask shader for exclusions. Default true.

Vegetation

float billboardCoverage

Snow on billboard vegetation. Range 0-2, default 1.4.

float grassCoverage

Snow on terrain grass. Range 0-1, default 0.75.

Events

OnUpdatePropertiesEvent OnUpdateProperties()

Called when snow properties are updated.

GlobalSnow.instance.OnUpdateProperties = () => {
    Debug.Log("Snow properties changed");
};
OnUpdateCoverageEvent OnBeforeUpdateCoverage()

Called before the coverage texture is updated.

OnUpdateCoverageEvent OnPostUpdateCoverage()

Called after the coverage texture has been updated.

Static Flags

static bool needUpdateSnowCoverage

Set to true to trigger a coverage update on the next frame.

static bool needFootprintBlit

Set to true to force a footprint texture blit on the next frame.

static bool needRebuildCommandBuffer

Set to true to rebuild the snow command buffer on the next frame.

Methods

void UpdateMaterialProperties()

Queues an update of all snow material properties. Call after modifying properties at runtime.

void UpdateMaterialPropertiesNow()

Immediately updates all snow material properties (synchronous).

void UpdateSnowCoverage()

Forces a recalculation of the coverage depth texture.

void RefreshExcludedObjects(bool performFullSceneScan = false)

Refreshes the excluded objects list. Pass true to scan the entire scene.

void UpdateSnowfallProperties()

Updates the snowfall particle system with current settings.

void UpdateSnowdustProperties()

Updates the snow dust particle system with current settings.

float GetSnowAmountAt(Vector3 position)

Returns the snow amount at a world position (0 = no snow, >0 = snow present).

CommandBuffer GetExclusionCommandBuffer()

Returns the command buffer used for exclusion rendering. Useful for advanced custom integrations.

Terrain Marks & Footprints Methods

void MarkSnowAt(Vector3 position)

Stamps a terrain mark at the specified position using the default size.

void MarkSnowAt(Vector3 position, float radius)

Stamps a terrain mark with a custom radius.

void FootprintAt(Vector3 position, Vector3 moveDir)

Stamps a footprint oriented along the movement direction.

void CollisionStay(Vector3 position, float radius)

Notifies the snow system of a continuous collision at a position. Creates terrain marks.

void CollisionStop()

Notifies the snow system that the collision has ended.

Coverage Mask Methods

void MaskPaint(Vector3 pos, byte value, float brushWidth, float brushOpacity = 1f, float brushFuzziness = 0f)

Paints the coverage mask. Value 0 = remove snow, 255 = full snow.

void MaskClear(byte value = 255)

Clears the entire mask to the specified value. Default 255 restores full snow.

void MaskFillArea(GameObject go, byte value, float opacity = 1f, float border = 0f)

Fills the mask area occupied by a GameObject's bounds.

void MaskFillArea(Bounds bounds, byte value, float opacity = 1f, float fallOff = 0)

Fills the mask within specified Bounds.

void MaskFillArea(Vector3 center, Vector3 size, byte value, float opacity = 1f, float fallOff = 0)

Fills the mask at a center position with a given size.

void SubmitCoverageMaskTextureChanges()

Submits pending mask texture changes to the GPU. Call after modifying the mask texture directly.

Static Methods

static void RegisterSnowSurface(SnowSurface surface)

Registers a SnowSurface component with the snow system.

static void UnregisterSnowSurface(SnowSurface surface)

Unregisters a SnowSurface component from the snow system.

static List<SnowSurface> GetSnowSurfaces()

Returns all currently registered SnowSurface components.

static void IgnoreGameObject(GlobalSnowIgnoreCoverage obj)

Excludes a GameObject from snow coverage at runtime.

static void UseGameObject(GlobalSnowIgnoreCoverage obj)

Re-includes a previously excluded GameObject.

SnowSurface

Component that generates a deformable snow mesh on terrain or custom geometry. URP exclusive.

Properties

LayerMask terrainLayerMask

Terrain layers the snow surface conforms to.

float geometryMetersPerVertex

Vertex spacing in meters. Min 0.1, default 0.25.

Vector2 geometrySize

Snow surface area in meters. Default 2x2.

int geometryMaxResolution

Max vertex count per axis. Range 8-1024, default 256.

float simplificationNormalThreshold

Angle threshold for mesh simplification. Range 0-90, default 15.

float pressureMaxSinkDepth

Max sink depth under pressure. Min 0, default 0.05.

float pressureSinkSpeed

Compression speed. Min 0, default 0.25.

float pressureDefaultRadius

Default pressure radius. Min 0, default 0.25.

float snowOverflow

Snow piling around depressions. Range 0-0.5.

float snowOverflowBorder

Width of overflow rim. Range 0.01-0.25, default 0.05.

int GeometryResolutionX read-only

Current vertex count along X axis.

int GeometryResolutionZ read-only

Current vertex count along Z axis.

bool IsSimplified read-only

Whether the mesh has been simplified.

Methods

void GetTriangleCounts(out int original, out int current)

Returns original and current (simplified) triangle counts.

void CaptureBrushStartState()

Captures mesh state for a brush operation starting point.

void ReleaseBrushStartState()

Releases captured brush state and frees memory.

GlobalSnowProfile

ScriptableObject for saving and loading snow configurations. Create via Create > Global Snow Profile.

void ApplyTo(GlobalSnow snow)

Applies all profile settings to the snow instance.

void CopyFrom(GlobalSnow snow)

Captures current snow settings into this profile.

static void Lerp(GlobalSnow gs, GlobalSnowProfile p1, GlobalSnowProfile p2, float t)

Interpolates between two profiles and applies the result. t is 0-1.

GlobalSnowProfile.Lerp(GlobalSnow.instance, autumnProfile, winterProfile, t);

Code Examples

Basic Runtime Control

using UnityEngine;
using GlobalSnowEffect;

public class SnowController : MonoBehaviour {
    void Start() {
        GlobalSnow snow = GlobalSnow.instance;
        snow.snowAmount = 0.5f;
        snow.snowTint = Color.white;
        snow.smoothness = 0.7f;
        snow.subsurfaceScattering = 0.4f;
        snow.preserveGI = true;
        snow.UpdateMaterialProperties();
    }
}

Season Transitions with Profiles

using UnityEngine;
using GlobalSnowEffect;

public class SeasonSystem : MonoBehaviour {
    public GlobalSnowProfile autumnProfile;
    public GlobalSnowProfile winterProfile;
    public float transitionDuration = 5f;
    float t;

    void Update() {
        t += Time.deltaTime / transitionDuration;
        GlobalSnowProfile.Lerp(GlobalSnow.instance,
            autumnProfile, winterProfile, Mathf.Clamp01(t));
    }
}

Dynamic Snowfall

using UnityEngine;
using GlobalSnowEffect;

public class WeatherController : MonoBehaviour {
    public void StartBlizzard() {
        GlobalSnow snow = GlobalSnow.instance;
        snow.snowfall = true;
        snow.snowfallIntensity = 0.8f;
        snow.snowfallWind = 1.5f;
        snow.cameraFrost = true;
        snow.cameraFrostIntensity = 0.8f;
        snow.snowdustIntensity = 0.7f;
        snow.UpdateMaterialProperties();
    }
}

Query Snow at Position

using UnityEngine;
using GlobalSnowEffect;

public class SnowDetector : MonoBehaviour {
    void Update() {
        float amount = GlobalSnow.instance.GetSnowAmountAt(transform.position);
        if (amount > 0.5f) {
            // Play snow footstep sounds, slow movement, etc.
        }
    }
}

Coverage Mask - Clear Snow Under Buildings

using UnityEngine;
using GlobalSnowEffect;

public class BuildingExclusion : MonoBehaviour {
    public GameObject building;

    void Start() {
        GlobalSnow snow = GlobalSnow.instance;
        snow.coverageMask = true;
        snow.MaskFillArea(building, 0, 1f, 2f);
    }
}
Was this page helpful?