LYGIA Shader Library

mod289 (lygia/math/mod289)

modulus of 289

Use:

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

Check it on Github


#ifndef FNC_MOD289
#define FNC_MOD289

float mod289(const in float x) { return x - floor(x * (1. / 289.)) * 289.; }
vec2 mod289(const in vec2 x) { return x - floor(x * (1. / 289.)) * 289.; }
vec3 mod289(const in vec3 x) { return x - floor(x * (1. / 289.)) * 289.; }
vec4 mod289(const in vec4 x) { return x - floor(x * (1. / 289.)) * 289.; }

#endif

Use:

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

Check it on Github

#ifndef FNC_MOD289
#define FNC_MOD289

float mod289(in float x) { return x - floor(x * (1. / 289.)) * 289.; }
float2 mod289(in float2 x) { return x - floor(x * (1. / 289.)) * 289.; }
float3 mod289(in float3 x) { return x - floor(x * (1. / 289.)) * 289.; }
float4 mod289(in float4 x) { return x - floor(x * (1. / 289.)) * 289.; }

#endif

Check it on Github


fn mod289(x: f32) -> f32 { return x - floor(x * (1. / 289.)) * 289.; }
fn mod289_2(x: vec2f) -> vec2f { return x - floor(x * (1. / 289.)) * 289.; }
fn mod289_3(x: vec3f) -> vec3f { return x - floor(x * (1. / 289.)) * 289.; }
fn mod289_4(x: vec4f) -> vec4f { return x - floor(x * (1. / 289.)) * 289.; }

Dependencies:

Use:

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

Check it on Github



#ifndef FNC_MOD289
#define FNC_MOD289

inline __device__ __host__ float mod289(float x) { return x - floor(x * (1.0f / 289.0f)) * 289.0f; }
inline __device__ __host__ float2 mod289(const float2& x) { return x - floor(x * (1.0f / 289.0f)) * 289.0f; }
inline __device__ __host__ float3 mod289(const float3& x) { return x - floor(x * (1.0f / 289.0f)) * 289.0f; }
inline __device__ __host__ float4 mod289(const float4& x) { return x - floor(x * (1.0f / 289.0f)) * 289.0f; }

#endif

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