Configuring humanoid characters to leave footprints on snow
By placing a collider on each foot and using the Global Snow Collider Extra Info, a snow mark will be left when each foot touches the ground as explained in this video:
Moving Objects (characters, vehicles, etc.)
Global Snow works with g-buffers and by default it doesn’t differentiate moving objects from static objects. Snow on moving objects can look strange on certain moving objects since snow will show alterations as the object moves. To avoid this issue, you have two options:
Step 1) Exclude snow on the moving object. You can do so by assigning the object or prefab to a exclusion layer in Global Snow coverage section. This way the object won’t receive the normal snow that Global Snow renders over the scene. Another way to exclude gameobjects from Global Snow is adding the Global Snow Ignore Coverage script to the gameobject itself (note that when using the exclusion options, the result might not be accurate in SceneView due to how CommandBuffers work – always verify the result in the GameView).
Step 2) Use a snow custom shader. If you want the moving object to show some snow, use the GlobalSnow/Moving Object Snow/Opaque shader included in the asset. This shader is a Standard shader-based shader that integrates snow features on it. The benefit of this shader is that the rendered snow on top of the moving gameobject doesn’t change its shape when the object or character moves, which produces a more realistic effect.
This shader includes a few appearance options as you can check in the screenshot above, including Snow Tint Color, Coverage (amount of snow), Snow Scale, Scatter, etc. Experiment with the different settings until you get the desired result.
Step 3) If the moving object is a vehicle and you want Global Snow to leave snow tracks after its wheels, add the Global Snow Collider Extra Info to the root of the vehicle gameobject. This script takes care of checking the contact points of wheels and ground and report those hits to Global Snow.
Snow Volumes
Global Snow volumes are special areas where snow can be completely disabled. When the player enters a snow volume, the snow disappears and when he exists the area, the snow script is re-enabled automatically.
To add a Global Snow Volume to your scene, just drag & drop the GlobalSnow Volume prefab from the GlobalSnow/Resources/Prefabs folder.
Position the volume in your scene as you do with a normal object. Change the collider scale to match the desired area size.
Mask Editor
Another way to remove/add snow on custom areas is by using a coverage mask:
A coverage mask is a special texture whose alpha component determines the opacity of the snow at a given location. The texture is overlaid over the world space at “World Center” with extents of “World Size” (so a size of 2000 means a coverage of -2000 to 2000).
You can provide your own texture mask or use the integrated SceneView editor. This mask editor is enabled using the provided section in the inspector:
The Mask Editor allows you to create a new mask texture from scratch. Select a proper resolution according to the detail level you need. For gross results, a texture of 1024×1024 may be enough. If you need finer coverage details use a bigger texture (ie. 2048, 4096 or even 8192 pixels).
The brush mode, width, fuzziness and opacity controls the behaviour of the paint tool. When the Mask Editor is enabled you can remove or add snow into the SceneView directly!
Click “Fill Mask” to reset the mask texture to fully snowed. “Clear Mask” will remove all snow from the covered area.
Please note that if you use Unity standard tree or grass you also need to edit the GlobalSnowForwardOptions.cginc or GlobalSnowDeferredOptions.cginc file (depending on the active camera rendering path) and enable the #define GLOBALSNOW_MASK line.
Complete Coverage
It’s possible to disable the zenithal coverage computation if your setup requires/allows that. Normally, objects in the scene will occlude snow beneath them (no snow below). This kind of occlusion is implemented by using a second zenithal camera that takes discrete depth shots from above. That information is used in the main snow shader to ensure no snow is rendered below any other object.
Currently you can have the “zenithal depth shots” to occur every frame, at discrete intervals or in manual mode. Discrete intervals means that a new zenithal depth capture will be taken every 50 meters as the player moves across the scene. Manual means that the shot is taken only with a call to UpdateSnowCoverage() method.
If you don’t need the zenithal depth pass, then you can set Coverage Update to Manual and edit GlobalSnowDeferredOptions.cginc or GlobalSnowForwardOptions.cginc file and comment out the line below:
// Comment out to disable zenithal depth
#define USE_ZENITHAL_DEPTH
VertExmotion integration
If you exclude some characters from snow coverage that use VertExmotion asset, you need to enable the integration to avoid artifacts.
-
In deferred rendering path locate and edit the file GlobalSnowDeferredOptions.cginc inside Resources/Workflow_Deferred folder.
-
In forward rendering path the file is named GlobalSnowForwardOptions.cginc inside Resources/Workflow_Forward folder.
Uncomment the following two lines and make sure the path in the include line is correct:
#define ENABLE_VERTEXMOTION_INTEGRATION
#include "Assets/VertExmotion/Shaders/VertExmotion.cginc"
Vehicle Physics Pro integration
Global Snow works out of the box with assets like Vehicle Physics Pro which implements wheel-based collision on the ground to leave snow tracks as covered in the “Moving Objects” section.
Step 1: Ensure your vehicle reports correct ground hits adding “Global Snow Collider Extra Info” script to the root of your vehicle prefab or gameobject. This script is necessary to detect wheel collisions and report them to Global Snow.
Step 2: Since the vehicle is a moving object, you will want to exclude it from Global Snow coverage (add it to a exclusion layer or add the Global Snow Ignore Coverage script to the root of the vehicle). Then, use the Global Snow/Moving Object Snow/Opaque shader to the materials of the vehicle in order to add static snow coverage on top of the vehicle parts.
Transition/Lerping between snow profiles
All global snow properties are animatable but also the asset includes a Global Snow Lerp script which allows you to quickly lerp between two sets of values.
Just create a gameobject and add the “Global Snow Lerp” script to it (you can also add this script to the camera):
The main settings are:
-
Target Global Snow: this will be automatically picked by the script upon start but lets you assign a different object (useful if you instantiate the player camera after scene is loaded).
-
Transition: value from 0 to 1. A value of 0 will use the settings of profile 1 while a value of 1 will use the settings of profile 2. Any value in between will mix the values from profiles 1 and 2 producing a smooth transition of the effect.
-
Left / Right Key: allows you to specify keys which will decrease/increase the transition value when pressing them in playmode.
-
Profile1 and Profile2: settings for global snow.