# Creating a material which clips the owning mesh by an input mesh

**URL:** <https://forums.unrealengine.com/t/creating-a-material-which-clips-the-owning-mesh-by-an-input-mesh/2635637>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, Shaders, shader, question\
**Created:** [August 9, 2025, 7:45am UTC](https://forums.unrealengine.com/t/creating-a-material-which-clips-the-owning-mesh-by-an-input-mesh/2635637 "2025-08-09T07:45:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrm\_dev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mrm\_dev](https://forums.unrealengine.com/u/mrm_dev)\
**Post date:** [August 9, 2025, 7:45am UTC](https://forums.unrealengine.com/t/creating-a-material-which-clips-the-owning-mesh-by-an-input-mesh/2635637/1 "2025-08-09T07:45:16Z")

</div>

I’m trying to create a material which takes an input mesh and clips parts of the material owning mesh which are outside it

I tried doing this with a primitive shape sphere (as “input mesh”) on a cube (“owning mesh”) as such:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/d/e/9debd1db604d70f22bb8dff05d5c892938cc4ded.jpeg)

hlsl code:

```auto
float dist = distance(WorldPosition, SphereCenter);
if (dist > SphereRadius)
{
   discard;
}

return 1.0;

```

and it works but is there a universal way to do this with any input mesh? not just with primitives like sphere or cube where I’d have to hardcode the equation
