Clipping Plane in URP

Hi,

I’m trying to make a clipping plane for my game that will make objects disappear as they pass through it. I found a tutorial that does this, but it doesn’t work with URP. This is the tutorial here: Clipping a Model with a Plane | Ronja's tutorials

I don’t know anything about shaders or how to change them, so I don’t know if it’s even possible to do something like this in URP, but if it is what would I have to change to make it work?

Any help is appreciated, Thanks

Clipping in ShaderGraph is a bit weird because every node is expected to have at least one output value used in the graph and is ignored otherwise. This means that you can’t just put an HLSL clip() in a custom function node. You have two options:

  1. Use clip() in a custom function node but produce a “dummy” output in the custom function node that you somehow use in the graph. I explain this technique here: URP - Render only whats inside a cube (Unity Answers). That was for a cube but it’s almost the same for a single plane.
  2. (Ab)use the alpha clip mechanism. You can enable alpha clipping in the graph settings of a URP Shader Graph. This will add two new output blocks: Alpha and Alpha Clip Threshold. Any fragment where Alpha is less than Alpha Clip Threshold will be removed. Set Alpha Clip Threshold to 0 and Alpha to the signed distance to the plane to clip everything below the plane. Here is an example graph:

The properties Point and Normal define the plane. Point is a point on the plane and Normal is a vector orthogonal to the plane. For example, for the XZ plane, set Point to (0, 0, 0) and Normal to (0, 1, 0).