LYGIA Shader Library

invQuartic (lygia/math/invQuartic)

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

Use:

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

Check it on Github


#ifndef FNC_INVQUARTIC
#define FNC_INVQUARTIC 
float invQuartic(const in float v) { return sqrt(1.0-sqrt(1.0-v)); }
vec2  invQuartic(const in vec2 v)  { return sqrt(1.0-sqrt(1.0-v)); }
vec3  invQuartic(const in vec3 v)  { return sqrt(1.0-sqrt(1.0-v)); }
vec4  invQuartic(const in vec4 v)  { return sqrt(1.0-sqrt(1.0-v)); }
#endif

Use:

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

Check it on Github


#ifndef FNC_INVQUARTIC
#define FNC_INVQUARTIC 
float   invQuartic(const in float v)    { return sqrt(1.0-sqrt(1.0-v)); }
float2  invQuartic(const in float2 v)   { return sqrt(1.0-sqrt(1.0-v)); }
float3  invQuartic(const in float3 v)   { return sqrt(1.0-sqrt(1.0-v)); }
float4  invQuartic(const in float4 v)   { return sqrt(1.0-sqrt(1.0-v)); }
#endif

Check it on Github


fn invQuartic(v: f32) -> f32 { return sqrt(1.0-sqrt(1.0-v)); }
fn invQuartic2(v: vec2f) -> vec2f { return sqrt(1.0-sqrt(1.0-v)); }
fn invQuartic3(v: vec3f) -> vec3f { return sqrt(1.0-sqrt(1.0-v)); }
fn invQuartic4(v: vec4f) -> vec4f { return sqrt(1.0-sqrt(1.0-v)); }

Dependencies:

Use:

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

Check it on Github



#ifndef FNC_INVQUARTIC
#define FNC_INVQUARTIC 
inline __host__ __device__ float   invQuartic(float v)    { return sqrt(1.0f - sqrt(1.0f - v)); }
inline __host__ __device__ float2  invQuartic(const float2& v)   { return sqrt(1.0f - sqrt(1.0f - v)); }
inline __host__ __device__ float3  invQuartic(const float3& v)   { return sqrt(1.0f - sqrt(1.0f - v)); }
inline __host__ __device__ float4  invQuartic(const float4& v)   { return sqrt(1.0f - sqrt(1.0f - v)); }
#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