LYGIA Shader Library

invCubic (lygia/v1.2.0/math/invCubic)

inverse cubic polynomial https://iquilezles.org/articles/smoothsteps/

Use:

<float|vec2|vec3|vec4> invCubic(<float|vec2|vec3|vec4> value);

Check it on Github


#ifndef FNC_INVCUBIC
#define FNC_INVCUBIC 

float invCubic(const in float v) { return 0.5-sin(asin(1.0-2.0*v)/3.0); }
vec2  invCubic(const in vec2 v)  { return 0.5-sin(asin(1.0-2.0*v)/3.0); }
vec3  invCubic(const in vec3 v)  { return 0.5-sin(asin(1.0-2.0*v)/3.0); }
vec4  invCubic(const in vec4 v)  { return 0.5-sin(asin(1.0-2.0*v)/3.0); }

#endif

Use:

<float|float2|float3|float4> invCubic(<float|float2|float3|float4> value);

Check it on Github


#ifndef FNC_INVCUBIC
#define FNC_INVCUBIC 

float   invCubic(const in float v)  { return 0.5-sin(asin(1.0-2.0*v)/3.0); }
float2  invCubic(const in float2 v) { return 0.5-sin(asin(1.0-2.0*v)/3.0); }
float3  invCubic(const in float3 v) { return 0.5-sin(asin(1.0-2.0*v)/3.0); }
float4  invCubic(const in float4 v) { return 0.5-sin(asin(1.0-2.0*v)/3.0); }

#endif

Dependencies:

Use:

<float|float2|float3|float4> invCubic(<float|float2|float3|float4> value);

Check it on Github



#ifndef FNC_INVCUBIC
#define FNC_INVCUBIC 

inline __host__ __device__ float   invCubic(float v)  { return 0.5-sin(asin(1.0f - 2.0f * v) / 3.0f); }
inline __host__ __device__ float2  invCubic(const float2& v) { return 0.5-sin(asin(1.0f - 2.0f * v) / 3.0f); }
inline __host__ __device__ float3  invCubic(const float3& v) { return 0.5-sin(asin(1.0f - 2.0f * v) / 3.0f); }
inline __host__ __device__ float4  invCubic(const float4& v) { return 0.5-sin(asin(1.0f - 2.0f * v) / 3.0f); }

#endif

Examples

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