lygia
/math
/invCubic
)inverse cubic polynomial https://iquilezles.org/articles/smoothsteps/
Use:
<float|vec2|vec3|vec4> invCubic(<float|vec2|vec3|vec4> value);
#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);
#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
Use:
<float|float2|float3|float4> invCubic(<float|float2|float3|float4> value);
#ifndef FNC_INVCUBIC
#define FNC_INVCUBIC
float invCubic(const float v) { return 0.5-sin(asin(1.0-2.0*v)/3.0); }
float2 invCubic(const float2 v) { return 0.5-sin(asin(1.0-2.0*v)/3.0); }
float3 invCubic(const float3 v) { return 0.5-sin(asin(1.0-2.0*v)/3.0); }
float4 invCubic(const float4 v) { return 0.5-sin(asin(1.0-2.0*v)/3.0); }
#endif
fn invCubic(v: f32) -> fn32 { return 0.5-sin(asin(1.0-2.0*v)/3.0); }
fn invCubic2(v: vec2f) -> vec2f { return 0.5-sin(asin(1.0-2.0*v)/3.0); }
fn invCubic3(v: vec3f) -> vec3f { return 0.5-sin(asin(1.0-2.0*v)/3.0); }
fn invCubic4(v: vec4f) -> vec4f { return 0.5-sin(asin(1.0-2.0*v)/3.0); }
Dependencies:
Use:
<float|float2|float3|float4> invCubic(<float|float2|float3|float4> value);
#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
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.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository