LYGIA Shader Library

lerp (lygia/math/lerp)

expands mix to linearly mix more than two values

Use:

<float|float2|float3|float4> lerp(<float|float2|float3|float4> a, <float|float2|float3|float4> b, <float|float2|float3|float4> c [, <float|float2|float3|float4> d], <float> pct)

Check it on Github


#ifndef FNC_LERP
#define FNC_LERP
#define lerp(A, B, PCT) mix(A, B, PCT) 
#endif

Use:

<float|float2|float3|float4> lerp(<float|float2|float3|float4> a, <float|float2|float3|float4> b, <float|float2|float3|float4> c [, <float|float2|float3|float4> d], <float> pct)

Check it on Github


#ifndef FNC_LERP
#define FNC_LERP
#define lerp(A, B, PCT) mix(A, B, PCT) 
#endif

Dependencies:

Use:

lerp(<float|float2|float3|float4> a, <float|float2|float3|float4> b, <float|float2|float3|float4> c [, <float|float2|float3|float4> d], <float> pct)

Check it on Github



#ifndef FNC_LERP
#define FNC_LERP

inline __device__ __host__ float lerp(float a, float b, float t) { return a + t*(b - a); }

inline __device__ __host__ float2 lerp(const float2& a, const float2& b, float t) { return a + t*(b - a); }
inline __device__ __host__ float3 lerp(const float3& a, const float3& b, float t) { return a + t*(b - a); }
inline __device__ __host__ float4 lerp(const float4& a, const float4& b, float t) { return a + t*(b - a); }

inline __device__ __host__ float2 lerp(const float2& a, const float2& b, const float2& t) { return a + t*(b - a); }
inline __device__ __host__ float3 lerp(const float3& a, const float3& b, const float3& t) { return a + t*(b - a); }
inline __device__ __host__ float4 lerp(const float4& a, const float4& b, const float4& t) { return a + t*(b - a); }

#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