`lygia`

/`sdf`

/`boxSDF`

)generate the SDF of a box

Use:

```
<float> boxSDF( in <vec3> pos [, in <vec3> borders ] )
```

```
#ifndef FNC_BOXSDF
#define FNC_BOXSDF
float boxSDF( vec3 p ) {
vec3 d = abs(p);
return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0));
}
float boxSDF( vec3 p, vec3 b ) {
vec3 d = abs(p) - b;
return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0));
}
#endif
```

Use:

```
<float> boxSDF( in <float3> pos [, in <float3> borders ] )
```

```
#ifndef FNC_BOXSDF
#define FNC_BOXSDF
float boxSDF( float3 p ) {
float3 d = abs(p);
return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0));
}
float boxSDF( float3 p, float3 b ) {
float3 d = abs(p) - b;
return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0));
}
#endif
```

```
fn boxSDF( p: vec3f, b: vec3f ) -> f32 {
let d = abs(p) - b;
return min(max(d.x,max(d.y,d.z)),0.0) + length(vec3f(max(d.x, 0.0), max(d.y, 0.0), max(d.z, 0.0)));
}
```

LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.

Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).

It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository