Hiding part of an object overlapping an invisible volume without hiding the part behind the volume?

I’m relatively new to shaders/SRP and I’ve searched extensively for a solution with no luck, so please forgive me if this is a dumb question.

That said, any help would be GREATLY appreciated; I’ve been stuck on this for almost a week now.

I’m trying to create an effect where part of a VFX Graph is invisible within a volume. I’ve had a little success using the depth buffer along with Renderer Features; the portion of the VFX object that’s inside of the volume is hidden. The problem is it also hides any part of the object that’s behind the volume but not inside of it. This is not the desired functionality.

Here are some screenshots demonstrating my issue. All three are the same objects, just viewed from different angles.


The blue/yellow parts are the VFX graph object. It’s being hidden by overlapping an invisible volume underneath the red object. From this angle, it looks correct.


In this screenshot, the invisible volume is selected. It also looks correct from this angle.


The VFX object and volume are still in the same position, but the portion of the VFX object that should be visible (the part that isn’t within the volume) is hidden. This is not the desired effect. I want the part of the VFX object that isn’t overlapping the volume to be visible “through”/behind it.

I’m using URP. Any hints on how to successfully implement this effect would really make my day.

Thanks in advance!

A depth buffer approach won’t get you a bounds, but rather at best a screen space “height map” of sorts. You could render something very close to the camera to fill in the depth buffer completely, and then render an inverted cube with ZTest GEqual to open a “hole” into the depth buffer, but it’ll also punch through anything else in the scene meaning if there’s an opaque object between the camera and the area you want the particles to show, they’ll show behind that. You also can make particles that are between the box and the camera but not inside not show. Similar to how with your current setup you can’t make particles that are behind the box show.

The next approach would be a stencil based approach, but stencils are purely 2d screen space things. You could render a box that only renders to the stencil buffer, and then if the particles enter that part of the screen they could be visible. Like the depth based method there’s no way to keep or exclude particles that are inside the 3D volume, only the 2D screen space. Stencils have no volume so particles that are outside of the bounds of the box, either between it and the camera or behind the box, will still render. But the Visual Effect Graph has no support for stencils at all so there’s no way to make this work even if that approach was good enough.

The real true solution to doing any real 3d volume inclusion / exclusion is to use a custom shader with the box’s bounds passed in as a set of vector properties and you can compare the fragment position to the bounds to show or hide them accordingly. This is the only way to confine something to the volume of a box per pixel. But the Visual Effect Graph doesn’t support custom shaders, so that’s not an option either. You’d need to use the built in particle system to do this.

The only way to do anything like this with a Visual Effect Graph is to use a Kill attribute in the Output. But that can only fully exclude or include an entire particle.