MG Spatial Selection is an Unreal Engine plugin designed for high-performance, real-time spatial selection of actors within a volume.
Traditional RTS selection systems often rely on costly CPU raycasts or screen-space decals that struggle with complex geometry. MG Spatial Selection addresses these performance bottlenecks using a high-efficiency hybrid architecture:
- CPU: Optimized native box-overlap queries for actor detection.
- GPU: World-space mask rendering for pixel-perfect, terrain-aware visuals.
By moving the heavy lifting to the GPU and using Unreal's native collision for detection, the system avoids the overhead of massive raycast batches while ensuring the selection highlight perfectly conforms to any terrain.
The system is ideal for strategy games, editor tools, or any application requiring precise volume selection. It is fully integrated with Unreal's Material Editor through a custom C++ Material Expression (MG Selection Mask), providing a pixel-perfect, terrain-aware selection highlight that follows ground contours without any expensive CPU raycasts.
Integration is straightforward: attach the component to your character or player controller, define your collision channels, and implement the selection interface on any actor you wish to detect.
A demo with integrated plugin in action can be found below a link. MG Spatial Selection Demo UE5 Project
If you have any bug or crash, please open an issue in the GitHub repo.
If you have suggestions, questions or need help, you can always contact me
If you want to contribute, feel free to create a pull request.
- High-Performance Selection: Uses native
UBoxComponentfor efficient overlap detection using Unreal's collision system. - Dynamic Terrain-Aware Mask: A custom C++ Material Expression (
MG Selection Mask) provides a 3D box mask in shaders, allowing for high-performance visuals that perfectly follow terrain and geometry. - Material Parameter Collection (MPC) Integration: Automatically pushes selection bounds (Center, Extent, Opacity) to a configurable MPC for real-time shader interaction.
- Post-Selection Decay: Supports a smooth "fade-out" effect (
DecayTime) where the selection opacity gradually transitions to zero after the interaction is complete. - Stability and Performance: Includes multi-stage stabilization (coordinate rounding, movement thresholds, and smoothed edge gradients) to eliminate visual flickering in early post-process passes.
- Enhanced Input Integration: Ready-to-use with Unreal Engine's Enhanced Input system.
- Interface-Driven Interaction: Easily filter selectable actors using the
IMGSpatialSelectionInterface. - Batch Processing: Smart event broadcasting ensures singular updates per frame even with complex overlaps.
- Configurable Settings: Full control over selection height, collision channels, and material parameter names.
- Download and Place: Place the
MGSpatialSelectionfolder under your project'sPlugins/directory. - Activate Plugin: Restart the editor and ensure the MG Spatial Selection plugin is enabled in the Plugins window.
- Add Component: Add the
MGSpatialSelectionComponentto yourPlayerControllerorCharacter. - Configure Input:
- Assign a Selection Action (Enhanced Input) in the component settings.
- Bind your input logic to call
StartSelection()(Pressed) andFinishSelection()(Released) on the component. The system handles the update logic internally during the selection state, so you don't need to call any functions on Tick.
- Implement Interface: Add the
IMGSpatialSelectionInterfaceto any Actor classes you want to be selectable. - Set Up Materials: Use the provided
MGSpatialSelection_PPMpost-process material or create your own using theMG Selection Masknode.
The plugin includes a ready-to-use Material Parameter Collection (MPC) and a Post-Process Material to get you started immediately.

- Default MPC:
/MGSpatialSelection/MGSpatialSelection_MPC- This MPC is automatically assigned to the component.
- It contains parameters for
SelectionCenter,SelectionExtent, andSelectionOpacity.
- Sample Material:
/MGSpatialSelection/MGSpatialSelection_PPM- A pre-configured Post-Process Material that uses the selection mask to highlight the terrain.
- To use it, simply add it to a
PostProcessVolume's Rendering Features > Post Process Materials array.
Instead of building complex 3D math in the material editor, use the native C++ node:

- Search for MG Selection Mask in the Material Editor.
g2. Inputs:
WorldPos: Connect to Absolute World Position (Recommended: Check "Exclude Material Shader Offsets" on the position node to prevent TAA jitter).Center: Connect to aCollectionParameternode referencingSelectionCenterfrom the MPC.Extent: Connect to aCollectionParameternode referencingSelectionExtentfrom the MPC.
- Outputs: A 0-1 mask (with slight edge softening) that is
1inside the selection volume and0outside.
The UMGSpatialSelectionComponent provides several categories for customization:

CollisionChannels: The physics channels to overlap for actor detection (e.g., Pawn, PhysicsBody).SelectionHeight: The fixed Z-height of the selection volume.TraceChannel: The channel used for the ground hit (cursor deprojection).
SelectionMPC: The Material Parameter Collection to update.SelectionCenterParameterName/SelectionExtentParameterName: Custom string names for the MPC variables.SelectionOpacity: The baseline intensity of the selection effect.DecayTime: How many seconds it takes for the highlight to fade to zero after the selection is released.
SelectionAction: The Enhanced Input Action that triggers the selection. Note: You only need to bindStartSelectionto the Started event andFinishSelectionto the Completed/Canceled events. The component handles its own internal updates.bShowDebug: Toggle to visualize the physicalUBoxComponentin the world.UpdateThreshold: Movement threshold (in units) to filter out micro-jitter from MPC updates.
(CPU Logic) (GPU Rendering)
[Input] ──► [Selection Component] ──► [Overlap Detection] ──► [Interface Dispatch] ──► [MPC] ──► [Post Process] ──► [Selection Mask]
Why use a Post-Process Material instead of Decals?
While Decals are great, a Post-Process Material using the MG Selection Mask is more performant when selecting massive areas or many units. It allows for "Tactical Overlay" effects like grid lines, scanlines, or pulse effects that are perfectly pixel-consistent across the whole screen.
Does it support slanted terrain?
Yes. Because the system uses the 3D depth buffer (via World Position) to calculate the mask, the selection highlight will perfectly wrap around hills, mountains, and even vertical walls.
How do I change the highlight color?
Open the MGSpatialSelection_PPM material in the plugin's Content folder and change the color tint in the material graph.
This plugin is under MIT license. MIT License does allow commercial use. You can use, modify, and distribute the software in a commercial product without any restrictions.
However, you must include the original copyright notice and disclaimers.
If you like the plugin, you can support my work here:




