Scripting Support (C#)

advanced scripting

Global Snow · Scripting Support (C#)

Control Global Snow at runtime using the GlobalSnowEffect namespace. The snow effect is a camera-based MonoBehaviour accessible via the singleton GlobalSnow.instance.

using GlobalSnowEffect;

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

GlobalSnow

MonoBehaviour attached to the camera. 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 camera this snow effect is attached to.

GlobalSnowProfile profile

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

GameObject sun

Reference to the directional light used for snow lighting calculations.

Snow Appearance

float snowAmount

Overall snow intensity. Range 0 (no snow) to 2 (maximum snow, values above 1 increase coverage beyond terrain).

Color snowTint

Tint color applied to the snow surface.

float smoothness

Snow surface smoothness/glossiness.

float snowNormalsStrength

Strength of the normal map applied to the snow surface for detail.

float noiseTexScale

Scale of the noise texture used for snow variation.

float reliefAmount

Intensity of the relief/parallax mapping effect on snow.

bool occlusion

Enables ambient occlusion on the snow surface.

float occlusionIntensity

Intensity of the snow ambient occlusion effect.

float glitterStrength

Strength of the glitter/sparkle effect on the snow surface.

float maxExposure

Maximum exposure value for the snow. Controls brightness clamp.

float subsurfaceScattering

Intensity of subsurface scattering through the snow.

Color subsurfaceScatteringColor

Tint color for the subsurface scattering effect.

bool preserveGI

Preserves existing global illumination contribution on snowy surfaces.

float minimumGIAmbient

Minimum ambient GI level on snow surfaces when preserveGI is enabled.

Altitude & Coverage

float minimumAltitude

Minimum world-space altitude where snow appears.

float minimumAltitudeVegetationOffset

Additional altitude offset for vegetation snow coverage.

float altitudeScatter

Amount of randomness in the altitude-based snow distribution.

float altitudeBlending

Blending factor for altitude-based snow transitions.

bool useZenithalCoverage

Enables zenithal (top-down) depth coverage for accurate snow placement on complex geometry.

int coverageExtension

Extension of the coverage capture area around the camera.

int coverageResolution

Resolution of the coverage depth texture.

float groundCoverage

Ground-level snow coverage amount.

float groundCoverageRandomization

Randomization factor for ground coverage distribution.

Slope

float slopeThreshold

Slope angle threshold above which snow is removed. Higher values allow snow on steeper surfaces.

float slopeSharpness

Sharpness of the slope-based snow removal transition.

float slopeNoise

Amount of noise applied to slope-based snow edges.

Coverage Mask

bool coverageMask

Enables the coverage mask system for painting snow on/off areas.

Texture2D coverageMaskTexture

The coverage mask texture. White = snow, black = no snow.

Vector3 coverageMaskWorldSize

World-space size of the area covered by the mask texture.

Vector3 coverageMaskWorldCenter

World-space center of the coverage mask area.

bool coverageMaskFillOutside

When enabled, areas outside the mask are filled with snow. When disabled, areas outside are snow-free.

Snowfall

bool snowfall

Enables the snowfall particle system.

float snowfallIntensity

Intensity of the snowfall particles.

float snowfallSpeed

Falling speed of snowflakes.

float snowfallWind

Wind effect on falling snowflakes.

float snowfallDistance

Maximum rendering distance for snowfall particles.

bool snowfallUseIllumination

When enabled, snowfall particles are affected by scene lighting.

float snowdustIntensity

Intensity of the snow dust particle effect. Set to 0 to disable.

float snowdustVerticalOffset

Vertical offset for the snow dust particle emitter.

Camera Frost

bool cameraFrost

Enables the camera frost overlay effect.

float cameraFrostIntensity

Intensity of the camera frost effect.

float cameraFrostSpread

How far the frost spreads from the screen edges.

float cameraFrostDistortion

Amount of distortion caused by the frost overlay.

Color cameraFrostTintColor

Tint color for the frost overlay.

Terrain Marks

bool terrainMarks

Enables terrain marks (deformation trails left by objects moving through snow).

int terrainMarksDuration

Duration in seconds before terrain marks fade away. Set to a low value for long-lasting marks. Minimum value is 1 second.

float terrainMarksDefaultSize

Default size of terrain mark stamps.

float terrainMarksViewDistance

Maximum distance from the camera at which terrain marks are visible.

float terrainMarksRoofMinDistance

Minimum distance from overhead geometry to allow terrain marks (prevents marks under roofs).

bool terrainMarksAutoFPS

When enabled, terrain marks are generated automatically based on the character controller's movement.

float terrainMarksStepMaxDistance

Maximum distance between consecutive automatic terrain mark stamps.

float terrainMarksRotationThreshold

Minimum rotation angle change to trigger a new terrain mark stamp.

Footprints

bool footprints

Enables footprint stamps on the snow surface.

Texture2D footprintsTexture

Custom texture used for footprint stamps. If null, a default footprint shape is used.

bool footprintsAutoFPS

When enabled, footprints are generated automatically based on character movement.

int footprintsDuration

Duration in seconds before footprints fade. Set to 0 for permanent footprints.

float footprintsScale

Scale multiplier for the footprint stamps.

float footprintsObscurance

Darkening/obscurance intensity of the footprint stamps.

Layer & Exclusion

LayerMask layerMask

Layer mask that determines which objects receive snow coverage.

LayerMask zenithalMask

Layer mask used for zenithal depth coverage calculations.

int defaultExclusionLayer

Default layer index used for snow exclusion rendering.

float exclusionBias

Depth bias for the exclusion mask rendering.

bool exclusionDoubleSided

Renders exclusion objects as double-sided for better masking of complex geometry.

float exclusionDefaultCutOff

Default alpha cutoff for exclusion rendering of transparent objects.

Vegetation

float billboardCoverage

Snow coverage amount on billboard vegetation (trees, etc.).

float grassCoverage

Snow coverage amount on terrain grass.

bool addSnowToGrass

When enabled, snow is added to terrain grass objects.

Ground Check

CharacterController characterController

Reference to the character controller used for automatic footprint and terrain mark generation.

float groundDistance

Maximum distance to the ground for footprint/mark placement checks.

Delegate Fields

OnUpdatePropertiesEvent OnUpdateProperties()

Called whenever snow properties are updated. Assign a handler to react to configuration changes.

// Delegate: void OnUpdatePropertiesEvent()

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

Called before the snow coverage texture is updated. Assign a handler to modify coverage data before it is applied.

OnUpdateCoverageEvent OnPostUpdateCoverage()

Called after the snow coverage texture has been updated.

Methods

void UpdateMaterialProperties()

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

void UpdateMaterialPropertiesNow()

Immediately updates all snow material properties (synchronous). Use when you need changes applied before the next frame.

void UpdateSnowfallProperties()

Updates the snowfall particle system with current settings.

void UpdateSnowdustProperties()

Updates the snow dust particle system with current settings.

void UpdateSnowCoverage()

Forces a recalculation of the snow coverage depth texture.

void RefreshExcludedObjects(bool performFullSceneScan = false)

Refreshes the list of excluded objects. Pass true to scan the entire scene for objects with GlobalSnowIgnoreCoverage.

float GetSnowAmountAt(Vector3 position)

Returns the current snow amount at a world position (0 = no snow, 1 = full snow). Useful for gameplay logic.

Terrain Marks & Footprints Methods

void MarkSnowAt(Vector3 position)

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

void MarkSnowAt(Vector3 position, float radius)

Stamps a terrain mark at the specified world position with a custom radius.

void FootprintAt(Vector3 position, Vector3 moveDir)

Stamps a footprint at the specified position oriented along the movement direction.

Coverage Mask Methods

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

Paints the coverage mask at a world position. value 0 = remove snow, 255 = full snow. Controls brush width, opacity, and edge fuzziness.

void MaskClear(byte value = 255)

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

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

Fills the coverage mask area occupied by the given GameObject's bounds.

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

Fills the coverage mask within the specified Bounds.

void SubmitCoverageMaskTextureChanges()

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

Static Methods

static void IgnoreGameObject(GlobalSnowIgnoreCoverage obj)

Excludes a GameObject from snow coverage at runtime.

static void UseGameObject(GlobalSnowIgnoreCoverage obj)

Re-includes a previously excluded GameObject in snow coverage.

GlobalSnowProfile

ScriptableObject for saving and loading snow configurations. Create via Create > Global Snow Profile. All fields mirror GlobalSnow properties.

Methods

void ApplyTo(GlobalSnow snow)

Applies all profile settings to the specified GlobalSnow instance.

GlobalSnowProfile winterProfile = Resources.Load<GlobalSnowProfile>("Winter");
winterProfile.ApplyTo(GlobalSnow.instance);
void CopyFrom(GlobalSnow snow)

Captures the 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 to the snow instance. 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.glitterStrength = 0.3f;
        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 StartSnowfall() {
        GlobalSnow snow = GlobalSnow.instance;
        snow.snowfall = true;
        snow.snowfallIntensity = 0.8f;
        snow.snowfallSpeed = 1f;
        snow.snowfallWind = 0.3f;
        snow.cameraFrost = true;
        snow.cameraFrostIntensity = 0.5f;
        snow.UpdateMaterialProperties();
    }

    public void StopSnowfall() {
        GlobalSnow snow = GlobalSnow.instance;
        snow.snowfall = false;
        snow.cameraFrost = false;
        snow.UpdateMaterialProperties();
    }
}

Coverage Mask - Clear Snow Under Buildings

using UnityEngine;
using GlobalSnowEffect;

public class BuildingSnowExclusion : MonoBehaviour {
    public GameObject building;

    void Start() {
        GlobalSnow snow = GlobalSnow.instance;
        snow.coverageMask = true;
        // Remove snow under the building bounds
        snow.MaskFillArea(building, 0, 1f, 2f);
    }
}

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.
        }
    }
}

Manual Terrain Marks

using UnityEngine;
using GlobalSnowEffect;

public class VehicleSnowTrails : MonoBehaviour {
    public float markInterval = 0.5f;
    float timer;

    void Update() {
        timer -= Time.deltaTime;
        if (timer <= 0f) {
            timer = markInterval;
            GlobalSnow.instance.MarkSnowAt(transform.position, 1.5f);
        }
    }
}
Was this page helpful?