Xray Vision / Detective vision

About Xray Vision / Detective vision – Unity VFX & Shader Pack

Xray Vision / Detective vision Unity Asset Overview

If you have ever tried building a "detective mode" mechanic similar to Batman: Arkham, The Witcher, or Cyberpunk 2077, you know that rendering hidden geometry through solid environment walls can get messy fast. Early in my career, I saw developers solve this by duplicating scene cameras, rendering to low-res render textures, or replacing materials at runtime. Honestly, those legacy approaches wreck draw calls, create memory spikes, and ruin your batching efficiency.

The Xray Vision / Detective vision asset tackles this challenge at the shader level using custom depth testing, stencil buffer operations, and screen-space scanning effects. Instead of relying on brute-force multi-camera setups, it provides dedicated shaders and lightweight C# manager scripts that modify how objects pass Unity's depth test (`ZTest Greater`). Here is the key takeaway: when occluded by walls, your target meshes switch to an alternative rendering pass—displaying glowing outlines, holographic grids, or custom wireframe overlays—without cluttering your main render pipeline.

Core Technical Features & Highlights

From a rendering graphics pipeline standpoint, this asset strikes a solid balance between visual punch and runtime efficiency. It gives you direct control over stencil values, color ramps, scanline speeds, and edge detection thickness.

Shader Execution & Stencil Buffer Operations

The core mechanic relies on a multi-pass custom shader. The first pass renders normal geometry when visible to the camera (`ZTest LEqual`). The second pass executes only when the object is hidden behind environmental geometry (`ZTest Greater`). By configuring the Stencil Buffer Reference ID, you can dynamically highlight enemies, loot chests, or quest items in distinct colors through solid objects.

Render Pipeline Support & Shaders

Out of the box, the package works smoothly across the Standard Built-in Render Pipeline and the Universal Render Pipeline (URP). For URP setups, it utilizes custom Scriptable Render Features to isolate the target layer and render the see-through pass efficiently.

Key Technical Capabilities

Ideal Use Cases & Game Genres

In my experience, this asset isn't just restricted to traditional detective games; it fits into a wide variety of project types where visual feedback through walls is essential for gameplay clarity.

Stealth & Action-Adventure

Display enemy patrol routes, vision cones, and skeletal poses behind solid walls, giving players tactical information before invading restricted zones.

Sci-Fi & Cyberpunk RPGs

Perfect for tech-scanner abilities, allowing players to hack electronic conduits, locate hidden power boxes, or analyze target attributes through environmental clutter.

Tactical Shooters & Battle Royales

Implement heartbeat sensors, thermal scope overlays, or team wall-hack utilities during specific equipment activations or killstreak abilities.

Puzzle & Escape Room Games

Reveal hidden structural flaws, hidden UV writing, or concealed wiring schematics when the player equips specific headgear or lenses.

Quick-Start Unity Setup & Integration Guide

Setting up the visual pass is straightforward. Follow these core steps to get your detective vision running in your scene within minutes.

Step 1: Configure Layers & Render Features

Create a dedicated Layer in your Unity project named XRayTarget. Assign all interactables, enemies, or objects you want visible through walls to this layer. If you are on URP, add the included XRayRenderFeature to your Universal Render Pipeline Asset forward renderer data asset.

Step 2: Scripting the Activation Trigger

Attach the following custom controller to your player character or camera rig to dynamically toggle the vision mode and modulate the pulse effect via C#:

using UnityEngine;

namespace GameDev.VFX
{
    public class DetectiveVisionTrigger : MonoBehaviour
    {
        [Header("Scan Parameters")]
        [SerializeField] private LayerMask scanLayerMask;
        [SerializeField] private float scanRadius = 25.0f;
        [SerializeField] private KeyCode toggleKey = KeyCode.V;

        [Header("Shader Properties")]
        [SerializeField] private string shaderPropertyActive = "_XRayEnabled";
        [SerializeField] private string shaderPropertyCenter = "_PulseCenter";

        private bool isVisionActive = false;
        private int activePropertyHash;
        private int centerPropertyHash;

        private void Awake()
        {
            activePropertyHash = Shader.PropertyToID(shaderPropertyActive);
            centerPropertyHash = Shader.PropertyToID(shaderPropertyCenter);
        }

        private void Update()
        {
            if (Input.GetKeyDown(toggleKey))
            {
                ToggleDetectiveVision();
            }
        }

        public void ToggleDetectiveVision()
        {
            isVisionActive = !isVisionActive;
            
            // Set global shader vector for radial sonar pulse originating from player
            Shader.SetGlobalVector(centerPropertyHash, transform.position);
            Shader.SetGlobalFloat(activePropertyHash, isVisionActive ? 1.0f : 0.0f);

            Collider[] hits = Physics.OverlapSphere(transform.position, scanRadius, scanLayerMask);
            foreach (var hit in hits)
            {
                if (hit.TryGetComponent<Renderer>(out var targetRenderer))
                {
                    MaterialPropertyBlock block = new MaterialPropertyBlock();
                    targetRenderer.GetPropertyBlock(block);
                    block.SetFloat("_IsHighlighted", isVisionActive ? 1.0f : 0.0f);
                    targetRenderer.SetPropertyBlock(block);
                }
            }
        }
    }
}

Pros & Cons Assessment

Pros

Cons

Asset Details & Specifications

CategoryVFX / Shaders
Latest Versionv2.0.1
File Size18.50 MB
Added to PlatformJuly 24, 2026
Views2 views
Downloads1 downloads
Favourites1 favourites
Official StoreBuy Original License on Unity Asset Store →
Issue with Package?Report Broken Link →

Developers Who Downloaded This Also Downloaded

Related Unity VFX Assets