Build Tips

intermediate performance

Global Snow & Rain 3 · Troubleshooting & FAQ

Global Snow draws the snow with one main shader, Hidden/GlobalSnow, that contains many features. Unity compiles one version of the shader, called a shader variant, for each combination of features that the project can turn on. The first build can take a long time, mostly with Direct3D 11 on Windows. Later builds use the shader cache and are faster. You can reduce the number of variants, and the build time, by removing the features that your project does not use.

Shader Keywords

Each feature of the inspector uses one shader keyword.

KeywordFeature in the inspector
GLOBALSNOW_ZENITHAL_COVERAGEUse Zenithal Coverage.
GLOBALSNOW_COVERAGE_MASKCoverage Mask.
GLOBALSNOW_FLAT_SHADING and GLOBALSNOW_RELIEFComplexity set to Flat Shading or Relief Mapping. Normal Mapping uses neither of them.
GLOBALSNOW_FOOTPRINTSFootprints.
GLOBALSNOW_TERRAINMARKSCollision Marks.
GLOBALSNOW_RAINRain, Puddles and Wall Wetness.
GLOBALSNOW_FROSTFrost.
GLOBALSNOW_LAYERSnow Accumulation.

Edit the Shader

  1. Open Assets/GlobalSnow/Runtime/Resources/GlobalSnow/Shaders/GlobalSnow.shader.
  2. Search for the keyword. It can appear in more than one pass, so change every line where it appears.
  3. If your project never uses the feature, add // at the start of the line. The feature then stays off, even if you turn it on in the inspector.
  4. If your project always uses the feature, replace the line with #define, the keyword and the value 1, for example #define GLOBALSNOW_LAYER 1. The feature then stays in the shader in every scene.
  5. For Complexity, remove from the line the keywords of the modes that you do not use. If you use only one mode, apply step 3 or step 4 to the whole line.

For example, this line of the main pass adds the Frost feature:

#pragma multi_compile_local_fragment _ GLOBALSNOW_FROST

If your project never uses Frost, change it to:

// #pragma multi_compile_local_fragment _ GLOBALSNOW_FROST

Each keyword that you remove this way halves the number of variants of the pass. For example, in Unity 6.0 the main pass can have up to 2,304 variants, and without Rain and Frost it has 576.

Shader Control: the Shader Control asset lists the shaders and keywords of your project, shows how many variants each keyword adds to the build, and can turn keywords off without editing the shader files.
After an update: an update of Global Snow replaces GlobalSnow.shader, so apply your changes again after each update.

Next Steps

Was this page helpful?