LYGIA Shader Library

powFast (lygia/math/powFast)

fast approximation to pow()

Use:

<float> powFast(<float> x, <float> exp)

Check it on Github


#ifndef FNC_POWFAST
#define FNC_POWFAST

float powFast(const in float a, const in float b) { return a / ((1. - b) * a + b); }

#endif

Use:

<float> powFast(<float> x, <float> exp)

Check it on Github


#ifndef FNC_POWFAST
#define FNC_POWFAST

float powFast(const in float a, const in float b) { return a / ((1. - b) * a + b); }

#endif

Check it on Github


fn powFast(a: f32, b: f32) -> f32 { return a / ((1.0 - b) * a + b); }
fn powFast2(a: vec2f, b: vec2f) -> vec2f { return a / ((1.0 - b) * a + b); }
fn powFast3(a: vec3f, b: vec3f) -> vec3f { return a / ((1.0 - b) * a + b); }
fn powFast4(a: vec4f, b: vec4f) -> vec4f { return a / ((1.0 - b) * a + b); }

Dependencies:

Use:

<float> powFast(<float> x, <float> exp)

Check it on Github



#ifndef FNC_POWFAST
#define FNC_POWFAST

inline __host__ __device__ float powFast(float a, float b) { return a / ((1.0f - b) * a + b); }

#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