Partial Hiders
A Partial Hider is a shader-driven hider that fades out per-pixel at the edge of the fog, instead of toggling on and off as a whole. An object using a partial hider material is fully hidden deep in the fog, fully visible in clear line of sight, and smoothly faded right at the boundary.
Note
As of version 3.3.0, partial hiders require no component and no registration — they are entirely material/shader based. Just put a partial hider shader on the object's material.
Partial Hiders vs the Fog Of War Hider component
| Partial Hider (shader) | Fog Of War Hider (component) | |
|---|---|---|
| Setup | A shader on the material | A component + a Hider Behavior |
| Granularity | Per-pixel, smooth edge fade | Whole-object show/hide |
| Registration | None | Registered with the world |
| Gameplay events | No | Yes (OnHiderVisibilityChanged) |
| Best for | Many objects, soft edges, scenery | Discrete units, logic on reveal/hide |
Use partial hiders for smooth visual fading and large numbers of objects; use the component when you need gameplay logic (events, enabling/disabling behavior) on reveal.
How It Works
A partial hider shader samples the fog visibility at each fragment's world position and multiplies the object's alpha by it. The object must therefore be rendered with a transparent or cutout (alpha-based) material.
Using the Included Shaders
The package ships ready-to-use partial hider shaders under FogOfWar/Shaders/Partial Hiders/:
- 2D —
FOW/2D/ASE/PartialHider2D - Built-In RP — Partial Hider Cutout and Transparent variants (Shader Graph and Amplify Shader Editor)
- FOW Grid — a procedural grid example that renders as its own custom FOW plane
Assign one of these shaders to your object's material and you're done.
Adding Partial Hiding to Your Own Shader
You can add partial hiding to any custom shader by multiplying your final alpha by the fog visibility sample.
Shader Graph
Use the included PartialHiderLogic sub-graph, and multiply your shader's output alpha by its result.
Amplify Shader Editor
Use the included PartialHiderSubFunction node, and multiply your output alpha by its result.
Hand-written HLSL
Include the logic header and call the world-space sample function:
#include "Assets/FogOfWar/Shaders/FogOfWarLogic.hlsl"
// worldPos = the fragment's world position
float fowVisibility;
FOW_Sample_WS_float(worldPos, fowVisibility); // 0 = hidden, 1 = fully visible
// multiply your output alpha by the visibility
finalColor.a *= fowVisibility;
Tip
FOW_Sample_WS_float (and its _half variant) returns the fog visibility at a world position. FOW_Sample_float(position2D, height, out result) is also available if you already have a position on the fog plane.