LYGIA Shader Library

dither (lygia/color/dither)

Set of dither methods

Dependencies:

Use:

<vec4|vec3|float> dither(<vec4|vec3|float> value[, <float> time])

Check it on Github



#ifndef DITHER_FNC
#ifdef TARGET_MOBILE
#define DITHER_FNC ditherInterleavedGradientNoise
#else
#define DITHER_FNC ditherVlachos
#endif
#endif

#ifndef FNC_DITHER
#define FNC_DITHER

float dither(float v) { return DITHER_FNC(v); }
vec3 dither(vec3 v) { return DITHER_FNC(v); }
vec4 dither(vec4 v) { return DITHER_FNC(v); }

#endif

Dependencies:

Use:

<float4|float3|float> dither(<float4|float3|float> value[, <float> time])

Check it on Github


#ifndef TIME_SECS
#if defined(UNITY_COMPILER_HLSL)
#define TIME_SECS _Time.y
#endif
#endif

#ifndef RESOLUTION
#if defined(UNITY_COMPILER_HLSL)
#define RESOLUTION _ScreenParams
#endif
#endif


#ifndef DITHER_FNC
#ifdef TARGET_MOBILE
#define DITHER_FNC ditherInterleavedGradientNoise
#else
#define DITHER_FNC ditherVlachos
#endif
#endif

#ifndef FNC_DITHER
#define FNC_DITHER

float dither(float b, float2 fragcoord, const in float time) {
    return DITHER_FNC(b, fragcoord, time);
}

float3 dither(float3 rgb, float2 fragcoord, const in float time) {
    return DITHER_FNC(rgb, fragcoord, time);
}

float4 dither(float4 rgba, float2 fragcoord, const in float time) {
    return DITHER_FNC(rgba, fragcoord, time);
}

#ifdef TIME_SECS
float dither(float b, float2 fragcoord) {
    return dither(b, fragcoord, TIME_SECS);
}

float3 dither(float3 rgb, float2 fragcoord) {
    return dither(rgb, fragcoord, TIME_SECS);
}

float4 dither(float4 rgba, float2 fragcoord) {
    return dither(rgba, fragcoord, TIME_SECS);
}
#endif

#endif

Dependencies:

Use:

<float4|float3|float> dither(<float4|float3|float> value[, <float> time])

Check it on Github



#ifndef DITHER_FNC
#ifdef TARGET_MOBILE
#define DITHER_FNC ditherInterleavedGradientNoise
#else
#define DITHER_FNC ditherVlachos
#endif
#endif

#ifndef FNC_DITHER
#define FNC_DITHER

float dither(float v) { return DITHER_FNC(v); }
float3 dither(float3 v) { return DITHER_FNC(v); }
float4 dither(float4 v) { return DITHER_FNC(v); }

#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