LYGIA Shader Library

saturate (lygia/math/saturate)

clamp a value between 0 and 1

Use:

<float|vec2|vec3|vec4> saturation(<float|vec2|vec3|vec4> value)

Check it on Github


#if !defined(FNC_SATURATE) && !defined(saturate)
#define FNC_SATURATE
#define saturate(V) clamp(V, 0.0, 1.0)
#endif

Use:

<float|float2|float3|float4> saturation(<float|float2|float3|float4> value)

Check it on Github


#if !defined(FNC_SATURATE) && !defined(saturate)
#define FNC_SATURATE
#define saturate(V) clamp(V, 0.0, 1.0)
#endif

Dependencies:

Use:

<float|vec2|vec3|vec4> saturation(<float|vec2|vec3|vec4> value)

Check it on Github



#ifndef FNC_SATURATE
#define FNC_SATURATE

inline  __host__ __device__ float  saturate( float x ){ return clamp(x, 0.0f, 1.0f); }
inline  __host__ __device__ float2 saturate( const float2& x ){ return clamp(x, 0.0f, 1.0f); }
inline  __host__ __device__ float3 saturate( const float3& x ){ return clamp(x, 0.0f, 1.0f); }
inline  __host__ __device__ float4 saturate( const float4& x ){ return clamp(x, 0.0f, 1.0f); }

#endif

Examples

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