LYGIA Shader Library

bump (lygia/math/bump)

bump in a range between -1 and 1

Dependencies:

Use:

<float|vec3> bump(<float|vec3> x[], <float|vec3> k])

Check it on Github



#ifndef FNC_BUMP
#define FNC_BUMP

float bump(float x, float k){ return saturate( (1.0 - x * x) - k); }
vec3 bump(vec3 x, vec3 k){ return saturate( (1.0 - x * x) - k); }
float bump(float x) { return max(1.0 - x * x, 0.0); }
vec3 bump(vec3 x) { return max(vec3(1.,1.,1.) - x * x, vec3(0.,0.,0.)); }

#endif

Use:

<float|float3> bump(<float|float3> x [, <float|float3> k])

Check it on Github


#ifndef FNC_BUMP
#define FNC_BUMP

float bump(float x, float k){ return saturate( (1.0 - x * x) - k); }
float3 bump(float3 x, float3 k){ return saturate( (1.0 - x * x) - k); }
float bump(float x) { return max(1.0 - x * x, 0.0); }
float3 bump(float3 x) { return max(float3(1.,1.,1.) - x * x, float3(0.,0.,0.)); }

#endif

Dependencies:

Use:

<float|float3> bump(<float|float3> x[], <float|float3> k])

Check it on Github



#ifndef FNC_BUMP
#define FNC_BUMP

float bump(float x, float k){ return saturate( (1.0 - x * x) - k); }
float3 bump(float3 x, float3 k){ return saturate( (1.0 - x * x) - k); }
float bump(float x) { return max(1.0 - x * x, 0.0); }
float3 bump(float3 x) { return max(float3(1.,1.,1.) - x * x, float3(0.,0.,0.)); }

#endif

Check it on Github


fn bump(x: f32, k: f32) -> f32 { return saturate( (1.0 - x * x) - k); }
fn bump2(x: vec2f, k: vec2f) -> vec2f { return saturate( (1.0 - x * x) - k); }
fn bump3(x: vec3f, k: vec3f) -> vec3f { return saturate( (1.0 - x * x) - k); }
fn bump4(x: vec4f, k: vec4f) -> vec4f { return saturate( (1.0 - x * x) - k); }

Dependencies:

Use:

<float|float3> bump(<float|float3> x [, <float|float3> k])

Check it on Github



#ifndef FNC_BUMP
#define FNC_BUMP

inline __host__ __device__ float bump(const float x) { return max(1.0f - x * x, 0.0f); }
inline __host__ __device__ float bump(float x, float k){ return clamp( (1.0 - x * x) - k, 0.0f, 1.0f); }

inline __host__ __device__ float3 bump(const float3& x) { return max(make_float3(1.0f) - x * x, make_float3(0.0f)); }
inline __host__ __device__ float3 bump(const float3& x, const float3& k){ return saturate( (1.0f - x * x) - k); }

#endif

Examples

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