LYGIA Shader Library

opExtrude (lygia/v1.1.6/sdf/opExtrude)

extrude operation of a 2D SDFs into a 3D one

Use:

<float> opExtrude( in <vec3> p, in <float> sdf, in <float> h )

Check it on Github


#ifndef FNC_OPEXTRUDE
#define FNC_OPEXTRUDE

float opExtrude( in vec3 p, in float sdf, in float h ) {
    vec2 w = vec2( sdf, abs(p.z) - h );
    return min(max(w.x,w.y),0.0) + length(max(w,0.0));
}

#endif


Use:

<float> opExtrude( in <float3> p, in <float> sdf, in <float> h )

Check it on Github


#ifndef FNC_OPEXTRUDE
#define FNC_OPEXTRUDE

float opExtrude( in float3 p, in float sdf, in float h ) {
    float2 w = float2( sdf, abs(p.z) - h );
    return min(max(w.x,w.y),0.0) + length(max(w,0.0));
}

#endif


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.

Get the latest news and releases

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