In order to improve the quality of magic effects, flames, hazy smoke, etc., it is very important to make the boundaries where objects collide with the ground or walls blend naturally. The "Soft Particles" technology makes this possible, but when implementing it with URP's Shader Graph, it will not work at all if the node combination procedure or renderer settings are incorrect. In this article, we will explain the basic principle of soft particles in an easy-to-understand manner using the analogy of ``ice that becomes transparent the moment it enters water,'' and present a method for constructing nodes of materials that fit perfectly.

1. Understand with an analogy: ``Ice that melts into water and becomes invisible.''

Let's compare this unnatural boundary bug and the mechanism of soft particles, which is the solution, to ``Visual of submerging a thin plate of ice in water.''

Suppose you violently thrust a transparent acrylic plate (effect) into a sandy beach (3D model of the ground). Since the acrylic board is insoluble, anyone can see sharp straight cuts (intersecting lines with a strong CG feel) at the boundary where the sand and acrylic intersect.

On the other hand, what would happen if the plate to be pierced was ``a special ice plate (Soft Particles) that automatically changes color depending on the depth of the water when submerged in water, and only the boundary part that is in contact with the water melts into the water and blends in completely?'' This ice gradually assimilates itself to the color of the water (background color) in the boundary area where the depth (difference in depth) from the bottom (scene depth) approaches zero, eventually fading to transparency (alpha 0). Only the deep parts that protrude from the water surface are clearly visible, and the parts near the bottom of the water appear to blend in softly, so the unnatural intersecting lines of acrylic plates completely disappear, and the effect blends beautifully into the water.

Soft particles are a technology that instantly calculates ``how close the current pixel is to the background ground,'' and as the difference in distance (depth difference) approaches, the material's transparency (Alpha) is automatically and smoothly reduced to 0.

2. Solution A: Correct node connection procedure in Shader Graph

In order to implement this "fade based on depth difference with the background" in Shader Graph, create a node network that calculates the difference between the screen depth of the current rendering pixel (Screen Depth) and the depth of the scene in the background (Scene Depth).

Node construction steps:

  1. Open the Shader Graph editor and create a Screen Position node in the empty space (set the Mode to `Raw`).
  2. Connect from the `Out` port of ``Screen Position'' to the ``Split'' node and extract the W channel (this W value corresponds to the ``linear depth (distance)'' from the camera to the current drawing pixel).
  3. Next, create a 'Scene Depth' node (Sampling Mode set to `Eye` to get the linear depth of the background).
  4. Create a ``Subtract'' node that subtracts the W channel value of ``Screen Position'' from the output of ``Scene Depth'' (`Scene Depth - Screen Depth (W)`). This calculates the "distance difference" between the object and the ground.
  5. Connect more Divide nodes (or `Multiply`) to adjust this distance difference. The number you divide by (e.g. `0.5`) is the "softness distance (in meters)" until the fade is complete. It is common to make this value a property so that it can be adjusted externally.
  6. Be sure to connect a ``Saturate'' node (or limit it to 0 to 1 with `Clamp`) to prevent rendering from breaking down if the value becomes less than `0` or more than `1`.
  7. Finally, we Multiply this output value by the effect material's original alpha value and connect it to the `Alpha` port of the master stack.

With this node configuration, the alpha value of the border that touches the ground automatically approaches zero, completely eliminating the crisp, sharp straight line.

3. Solution B: Enabling URP Renderer Settings (Required Process)

Even if the nodes are assembled correctly in Shader Graph, the ground may slip through or not work. This is caused by the setting to generate background depth information as a texture on the URP renderer side is disabled.

Setup steps:

  1. In the project window, select the currently active "Universal Render Pipeline Asset (URP Asset)".
  2. In the Inspector, look for the checkbox labeled ``Depth Texture''.
  3. Be sure to **check (enable)** this ``Depth Texture''.

By checking this, Unity will generate ``_CameraDepthTexture'' that stores the depth information of the entire screen in GPU memory when it finishes drawing the opaque background object, and the Shader Graph's ``Scene Depth'' node will be able to sample the correct scene depth. This allows soft particles to work perfectly.