Reveals a texture only where a spotlight hits — works on any surface without modifying existing materials.

🎬 Watch on YouTube:(https://www.youtube.com/watch?v=Q_yG5qkPpzU)
Unity HDRP Any Unity version supporting Decal Projector
Unity does not support creating HLSL files directly. Open your project folder in File Explorer, create a new text file and rename it to UVReveal.hlsl (make sure file extensions are visible in Explorer). Paste the HLSL code inside.
Create an HDRP Decal Shader Graph, name it UVReveal. Inside the Shader Graph:
Add a Custom Function node → set Type to File, set Name to the function name without the _float suffix (e.g. UVReveal), and assign your UVReveal.hlsl to the Source field Add a Position (Absolute World) node → connect to the Custom Function's WorldPos input.
Note: I named the input WorldPos in the video by mistake — rename it to AbsoluteWorldPos to match the HLSL parameter.
Create a material from the UVReveal shader. Assign your texture and adjust the relevant fields on the material.
Make sure your texture has a proper alpha channel. Textures processed with a background remover tool work well.
Add a Decal Projector to your scene and assign your material to its Material slot. Repeat this for each surface you want to reveal — one Decal Projector per texture placement.
Add the UVLightController script to your spotlight object in the scene. The script automatically reads the light's position, direction and range — no additional assignment needed.
The script uses SetGlobalVector / SetGlobalFloat, meaning all materials using these shader variables in the scene are updated automatically with a single light source.
OnValidate was used during development for testing in the editor. Once you've set everything up, replace it with Update to run during gameplay (runtime).
Built with AI assistance — paste the HLSL code into any AI (ChatGPT, Claude, etc.) and ask how it works or how to modify it.
Textures used in the demo:
This project may not be the most optimal solution for a UV light effect, but it might still be useful or serve as a starting point to build upon.