LYGIA Shader Library

mmin (lygia/math/mmin)

extend GLSL min function to add more arguments

Use:

min(<float> A, <float> B, <float> C[, <float> D])
min(<vec2|vec3|vec4> A)

Check it on Github


#ifndef FNC_MMIN
#define FNC_MMIN

float mmin(const float v) { return v; }
float mmin(in float a, in float b) { return min(a, b); }
float mmin(in float a, in float b, in float c) { return min(a, min(b, c)); }
float mmin(in float a, in float b, in float c, in float d) { return min(min(a,b), min(c, d)); }

float mmin(const vec2 v) { return min(v.x, v.y); }
float mmin(const vec3 v) { return mmin(v.x, v.y, v.z); }
float mmin(const vec4 v) { return mmin(v.x, v.y, v.z, v.w); }

#endif

Use:

<float> mmin(<float> A, <float> B, <float> C[, <float> D])
<float2|float3|float4> mmin(<float2|float3|float4> A)

Check it on Github


#ifndef FNC_MMIN
#define FNC_MMIN

float mmin(in float a, in float b) { return min(a, b); }
float mmin(in float a, in float b, in float c) { return min(a, min(b, c)); }
float mmin(in float a, in float b, in float c, in float d) { return min(min(a,b), min(c, d)); }

float mmin(const float2 v) { return min(v.x, v.y); }
float mmin(const float3 v) { return mmin(v.x, v.y, v.z); }
float mmin(const float4 v) { return mmin(v.x, v.y, v.z, v.w); }

#endif

Use:

min(<float> A, <float> B, <float> C[, <float> D])
min(<float2|float3|float4> A)

Check it on Github


#ifndef FNC_MMIN
#define FNC_MMIN

float mmin(const float v) { return v; }
float mmin(float a, float b) { return min(a, b); }
float mmin(float a, float b, float c) { return min(a, min(b, c)); }
float mmin(float a, float b, float c, float d) { return min(min(a,b), min(c, d)); }

float mmin(const float2 v) { return min(v.x, v.y); }
float mmin(const float3 v) { return mmin(v.x, v.y, v.z); }
float mmin(const float4 v) { return mmin(v.x, v.y, v.z, v.w); }

#endif

Dependencies:

Use:

min(<float> A, <float> B, <float> C[, <float> D])
min(<float2|float3|float4> A)

Check it on Github



#ifndef FNC_MMIN
#define FNC_MMIN

inline __device__ __host__ float mmin(float a, float b) { return min(a, b); }
inline __device__ __host__ float mmin(float a, float b, float c) { return min(a, min(b, c)); }
inline __device__ __host__ float mmin(float a, float b, float c, float d) { return min(min(a,b), min(c, d)); }

inline __device__ __host__ float mmin(const float2& v) { return min(v.x, v.y); }
inline __device__ __host__ float mmin(const float3& v) { return mmin(v.x, v.y, v.z); }
inline __device__ __host__ float mmin(const float4& v) { return mmin(v.x, v.y, v.z, v.w); }

#endif

Licenses

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