Posted October 20, 2025 by Maxime
#unity #hdrp #outline #hlsl #custom pass #post process
The studio couldn't afford R&D, so I decided to build my own on my spare time.
The system is based on a Custom Pass. It renders every object in a specific layer into a buffer using the color assigned to that layer.
Then the buffer is:
Downsampled (for performance),
Blurred horizontally,
Blurred vertically,
And finally combined with the active render buffer; basically, one minus the other.
That last part is handled in HLSL via a shader called "OneMinusTheOther", paired with a C# custom render pass.
It supports up to 50 outline colors, and uses an _OutlineTexture to apply patterns like hatching directly in screen space.
Because it’s all done as a post-process, it works with any 3D renderer: static, skinned, instanced, doesn’t matter.
Performance turned out to be surprisingly strong, even in real-world conditions.
In a full game scene running at 4K, with anywhere between 600 and over 2,000 outlined objects (which is not a common use case), using several colors at once, the entire outline pass stays around 0.2 to 0.4 ms per frame on an RTX 4080 SUPER.
That’s remarkably efficient for HDRP, especially given the visual quality and flexibility of the effect. The whole system runs as a single post-process stage, and the impact on frame time is barely noticeable.
Of course, the exact numbers will depend on the scene and hardware, but in practice the pass remains consistently lightweight, rarely crossing half a millisecond per frame, even in demanding situations.
Visually, the result is very smooth, edges feel organic, sometimes even rounding corners slightly, but without creating “floating faces” like the common inverted-faces technique does.
Outlines can fade or blend into each other where colors meet, and it’s even possible to create gradient or textured effect thanks to the _OutlineTexture parameter.
It’s stylized, readable, and flexible enough for both highlighting and artistic rendering.
Honestly, this project went unusually smoothly. The technique is well documented, but bringing it to HDRP required a bit of translation work, Unity’s rendering stack can be intimidating at first glance.
In the end, the result feels clean, fast, and production-ready. It’s a good reminder that sometimes, the most efficient approach isn’t reinventing the wheel, it’s re-engineering it for the terrain you’re driving on.