# Decals using depth buffer (soft particles)

**URL:** <https://realtimevfx.com/t/decals-using-depth-buffer-soft-particles/28580>\
**Category:** General Discussion\
**Tags:** shaders, unity, unreal\
**Created:** [March 1, 2025, 3:07pm UTC](https://realtimevfx.com/t/decals-using-depth-buffer-soft-particles/28580 "2025-03-01T15:07:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hovl](https://realtimevfx.com/user_avatar/realtimevfx.com/hovl/32/15531_2.png) [@Hovl](https://realtimevfx.com/u/Hovl)\
**Post date:** [March 1, 2025, 3:07pm UTC](https://realtimevfx.com/t/decals-using-depth-buffer-soft-particles/28580/1 "2025-03-01T15:07:12Z")

</div>

Hi guys, has anyone ever thought of making decals using a depth buffer? I had the idea to invert the transparency and make the decals visible only near the surface. In this case, if the decal is on the edge of the model, then the part that goes beyond the limits will be invisible. What do you think?

---

<div class="post-metadata">

**Author:** ![bgolus](https://realtimevfx.com/user_avatar/realtimevfx.com/bgolus/32/2780_2.png) [@bgolus](https://realtimevfx.com/u/bgolus)\
**Post date:** [March 3, 2025, 6:56am UTC](https://realtimevfx.com/t/decals-using-depth-buffer-soft-particles/28580/2 "2025-03-03T06:56:04Z")

</div>

Indeed. That’s actually explicitly how deferred decals already work! Though usually they use the depth to also calculate the UV.

But a form more similar to what you’re describing ere used extensively in Sucker Punch’s Infamous: Second Son for on-character decals. They did a GDC talk on this 11 years ago, here’s the section where they show of how they used it.

[![](https://img.youtube.com/vi/o2yFxPY2b1o/maxresdefault.jpg "The Visual Effects of inFAMOUS: Second Son") ](https://www.youtube.com/watch?v=o2yFxPY2b1o&t=1460)

More recently, Tuatara posted an example with a minor tweak on the idea make these kinds of decals very cheaply look like they’re conforming to a surface.  
[https://x.com/Tuatara\_Games/status/1887561903251333217](https://x.com/Tuatara_Games/status/1887561903251333217)

It’s also a common way to do faked real time lights or glows very cheaply.

Some of the first games to use “decals” at all in the way we think of them today were implemented in this exact way, usually for things like bullet holes. Monolith’s (RIP) F.E.A.R. had extremely impressive bullet impacts on surfaces. They’re likely most remembered for being one of the first implementations of parallax occlusion mapping, _but_ they were also just quads that were up against the wall like many previous games… ones that used the depth buffer to make sure they wouldn’t be seen hanging off of corners, which previous games would have.

---

<div class="post-metadata">

**Author:** ![Hovl](https://realtimevfx.com/user_avatar/realtimevfx.com/hovl/32/15531_2.png) [@Hovl](https://realtimevfx.com/u/Hovl)\
**Post date:** [March 3, 2025, 1:36pm UTC](https://realtimevfx.com/t/decals-using-depth-buffer-soft-particles/28580/3 "2025-03-03T13:36:06Z")

</div>

Thank you, so it’s not something new 😅

---

<div class="post-metadata">

**Author:** ![Mousabelle](https://realtimevfx.com/letter_avatar_proxy/v4/letter/m/f05b48/32.png) [@Mousabelle](https://realtimevfx.com/u/Mousabelle)\
**Post date:** [October 13, 2026, 5:41pm UTC](https://realtimevfx.com/t/decals-using-depth-buffer-soft-particles/28580/5 "2026-10-13T17:41:35Z")

</div>

**To fix the decal projecting through the whole distance, you need to use the Decal Lifetime Opacity or calculate a distance mask in the material.** Usually, Parameter 1 and Parameter 2 from Niagara can be used to pass custom fade distances. In your material, take the `PixelDepth` or `CameraDepthFade`, compare it with the parameters passed from your Niagara Dynamic Parameter node using a `LinearInterpolate` (Lerp) or `SmoothStep`, and multiply that with your opacity mask. This will smoothly clip the decal based on the values you send from the emitter.

---

<div class="post-metadata">

**Author:** ![Humming](https://realtimevfx.com/letter_avatar_proxy/v4/letter/h/b5ac83/32.png) [@Humming](https://realtimevfx.com/u/Humming)\
**Post date:** [October 19, 2026, 4:39pm UTC](https://realtimevfx.com/t/decals-using-depth-buffer-soft-particles/28580/6 "2026-10-19T16:39:40Z")

</div>

The problem was a node connected wrong, my bad! Thanks for the reply buddy ✌

---

<div class="post-metadata">

**Author:** ![Hovl](https://realtimevfx.com/user_avatar/realtimevfx.com/hovl/32/15531_2.png) [@Hovl](https://realtimevfx.com/u/Hovl)\
**Post date:** [October 20, 2026, 6:46pm UTC](https://realtimevfx.com/t/decals-using-depth-buffer-soft-particles/28580/7 "2026-10-20T18:46:15Z")

</div>

Oh, I figured it out a long time ago. Here is a final version:

 ![image](https://realtimevfx.com/uploads/default/original/3X/8/b/8b360b49164ff2fee6d9ac88c3475752718e47d4.png)

---

<div class="post-metadata">

**Author:** ![Jukerlaw](https://realtimevfx.com/user_avatar/realtimevfx.com/jukerlaw/32/28483_2.png) [@Jukerlaw](https://realtimevfx.com/u/Jukerlaw)\
**Post date:** [October 20, 2026, 9:27pm UTC](https://realtimevfx.com/t/decals-using-depth-buffer-soft-particles/28580/8 "2026-10-20T21:27:50Z")

</div>

I just realize that the B mask need to be routed before the offset to make vertical fading correct.
