LYGIA Shader Library

permute (lygia/v1.1.6/math/permute)

permute

Dependencies:

Use:

permute(<float|vec2|vec3|vec4> x)

Check it on Github



#ifndef FNC_PERMUTE
#define FNC_PERMUTE

float permute(const in float v) { return mod289(((v * 34.0) + 1.0) * v); }
vec2 permute(const in vec2 v) { return mod289(((v * 34.0) + 1.0) * v); }
vec3 permute(const in vec3 v) { return mod289(((v * 34.0) + 1.0) * v); }
vec4 permute(const in vec4 v) { return mod289(((v * 34.0) + 1.0) * v); }

#endif

Dependencies:

Use:

permute(<float|float2|float3|float4> x)

Check it on Github



#ifndef FNC_PERMUTE
#define FNC_PERMUTE

float permute(in float x) { return mod289(((x * 34.0) + 1.0) * x); }
float2 permute(in float2 x) { return mod289(((x * 34.0) + 1.0) * x); }
float3 permute(in float3 x) { return mod289(((x * 34.0) + 1.0) * x); }
float4 permute(in float4 x) { return mod289(((x * 34.0) + 1.0) * x); }

#endif

Dependencies:

Check it on Github


fn permute(x: f32) -> f32 { return mod289_1(((x * 34.0) + 1.0) * x); }
fn permute2(x: vec2f) -> vec2f { return mod289_2(((x * 34.0) + 1.0) * x); }
fn permute3(x: vec3f) -> vec3f { return mod289_3(((x * 34.0) + 1.0) * x); }
fn permute4(x: vec4f) -> vec4f { return mod289_4(((x * 34.0) + 1.0) * x); }

Dependencies:

Use:

permute(<float|float2|float3|float4> x)

Check it on Github



#ifndef FNC_PERMUTE
#define FNC_PERMUTE

inline __device__ __host__ float permute(float x) { return mod289(((x * 34.0f) + 1.0f) * x); }
inline __device__ __host__ float2 permute(const float2& x) { return mod289(((x * 34.0f) + 1.0f) * x); }
inline __device__ __host__ float3 permute(const float3& x) { return mod289(((x * 34.0f) + 1.0f) * x); }
inline __device__ __host__ float4 permute(const float4& x) { return mod289(((x * 34.0f) + 1.0f) * x); }

#endif

Examples

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