A sample showing unit-based geometry culling. Environmental assets blocking a custom trace channel will automatically fade out when it is detected that a player unit is being visually occluded.
A sample showing cursor-based geometry culling. This was added in addition to the automatic unit-based culling to assist in sending move orders to units where environmental geometry would otherwise block cursor input.
Because Wartorn primarily uses a fixed-angle camera, there are unavoidable instances where either your player units or something you are attempting to interact with (an item, an enemy, etc.) is visually obscured by environmental geometry. This can be particularly frustrating in an RTS style game where it is critically important to be able to visually identify your units at a glance, as well as react to enemies attacking or damage being taken.
To solve this Wartorn implements a custom component attached to the game-camera that continually raycasts from the camera position to each unit position, detecting colliding geometry via a custom trace channel and fading out any relevant mesh components. Because there is the potential for a very large number of units to be visible on the screen at any given time adding a not-insignificant performance overhead, a queuing system was added to throttle the number of units processed on any given frame.
The visual effect itself is entirely material-based and simply uses temporal dithering combined with an opacity mask to either fade in or fade out the relevant geometry.