LYGIA Shader Library

mmax (lygia/v1.1.6/math/mmax)

extend GLSL Max function to add more arguments

Use:

max(<float> A, <float> B, <float> C[, <float> D])
max(<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:

max(<float> A, <float> B, <float> C[, <float> D])
max(<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

Dependencies:

Use:

max(<float> A, <float> B, <float> C[, <float> D])
max(<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

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