LYGIA Shader Library

mmax (lygia/math/mmax)

extend GLSL Max function to add more arguments

Use:

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

Check it on Github


#ifndef FNC_MMAX
#define FNC_MMAX

float mmax(in float a, in float b) { return max(a, b); }
float mmax(in float a, in float b, in float c) { return max(a, max(b, c)); }
float mmax(in float a, in float b, in float c, in float d) { return max(max(a, b), max(c, d)); }
float mmax(const vec2 v) { return max(v.x, v.y); }
float mmax(const vec3 v) { return mmax(v.x, v.y, v.z); }
float mmax(const vec4 v) { return mmax(v.x, v.y, v.z, v.w); }

#endif

Use:

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

Check it on Github


#ifndef FNC_MMAX
#define FNC_MMAX

float mmax(in float a, in float b) { return max(a, b); }
float mmax(in float a, in float b, in float c) { return max(a, max(b, c)); }
float mmax(in float a, in float b, in float c, in float d) { return max(max(a, b), max(c, d)); }

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

#endif

Check it on Github


fn mmax2(v: vec2f) -> f32 { return max(v.x, v.y); }
fn mmax3(v: vec3f) -> f32 { return mmax(v.x, v.y, v.z); }
fn mmax4(v: vec4f) -> f32 { return mmax(v.x, v.y, v.z, v.w); }

Dependencies:

Use:

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

Check it on Github



#ifndef FNC_MMAX
#define FNC_MMAX

inline __device__ __host__ float mmax(float a, float b) { return max(a, b); }
inline __device__ __host__ float mmax(float a, float b, float c) { return max(a, max(b, c)); }
inline __device__ __host__ float mmax(float a, float b, float c, float d) { return max(max(a, b), max(c, d)); }

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

#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