LYGIA Shader Library

sphereSDF (lygia/sdf/sphereSDF)

generate the SDF of a sphere

Use:

<float> sphereSDF( in <vec3> pos[], in <float> size] )

Check it on Github


#ifndef FNC_SPHERESDF
#define FNC_SPHERESDF
float sphereSDF(vec3 p) { return length(p); }
float sphereSDF(vec3 p, float s) { return sphereSDF(p) - s; }
#endif

Use:

<float> sphereSDF( in <float3> pos[], in <float> size] )

Check it on Github


#ifndef FNC_SPHERESDF
#define FNC_SPHERESDF
float sphereSDF(float3 p) { return length(p); }
float sphereSDF(float3 p, float s) { return sphereSDF(p) - s; }
#endif

Check it on Github

fn sphereSDF(p: vec3f, s: f32) -> f32 { 
    return length(p) - s; 
}

Dependencies:

Use:

<float> sphereSDF( in <float3> pos[], in <float> size] )

Check it on Github



#ifndef FNC_SPHERESDF
#define FNC_SPHERESDF

inline __host__ __device__ float sphereSDF(float3 p) { return length(p); }
inline __host__ __device__ float sphereSDF(float3 p, float s) { return sphereSDF(p) - s; }

#endif

License

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