# Clipping Solids (SDF functions)

**URL:** <https://discourse.threejs.org/t/clipping-solids-sdf-functions/4444>\
**Category:** Resources\
**Tags:** points, clipping, shaders\
**Created:** [October 9, 2018, 6:58pm UTC](https://discourse.threejs.org/t/clipping-solids-sdf-functions/4444 "2018-10-09T18:58:21Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Post date:** [October 9, 2018, 8:12pm UTC](https://discourse.threejs.org/t/clipping-solids-sdf-functions/4444/3 "2018-10-09T20:12:27Z")

</div>

> [@marquizzo](#):
>
> Or does it have to be defined by a mathematical equation, like the twisted cube?

Yes, the box is defined in the shader:

```javascript
// http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
float udBox( vec3 p, vec3 b )
{
  return length(max(abs(p)-b,0.0));
}

```

Unfortunately, I have no idea of how to do that stuff with arbitrary geometries.

The only way I can imagine is that you can model complex solids by combining the primitives described with the distance functions. But the more complex the model, the more complex shaders you get 🤔

Just have a look at the source code of the raymarching shader, there you can find all the functions for primitives:

> **[Shadertoy](https://www.shadertoy.com/view/Xds3zN)**
>
> Build shaders, share them, and learn from the best community.

> [@marquizzo](#):
>
> The best I’ve been able to do so far is to find the geometry faces via depthMap render.

Very cool idea! 👍

---

_[View the full topic](https://discourse.threejs.org/t/clipping-solids-sdf-functions/4444)._
