lygia
/filter
/boxBlur
)Given a texture it performs a moving average or box blur. Which simply averages the pixel values in a KxK window. This is a very common image processing technique that can be used to smooth out noise.
Dependencies:
lygia
/sampler
.glsl
lygia
/filter
/boxBlur
/1D
.glsl
lygia
/filter
/boxBlur
/2D
.glsl
lygia
/filter
/boxBlur
/2D_fast9
.glsl
Use:
boxBlur(<SAMPLER_TYPE> texture, <vec2> st, <vec2> pixel_offset)
#ifndef BOXBLUR_ITERATIONS
#define BOXBLUR_ITERATIONS 3
#endif
#ifndef BOXBLUR_TYPE
#define BOXBLUR_TYPE vec4
#endif
#ifndef BOXBLUR_SAMPLER_FNC
#define BOXBLUR_SAMPLER_FNC(TEX, UV) SAMPLER_FNC(TEX, UV)
#endif
#ifndef FNC_BOXBLUR
#define FNC_BOXBLUR
BOXBLUR_TYPE boxBlur13(in SAMPLER_TYPE tex, in vec2 st, in vec2 offset) {
#ifdef BOXBLUR_2D
return boxBlur2D(tex, st, offset, 7);
#else
return boxBlur1D(tex, st, offset, 7);
#endif
}
BOXBLUR_TYPE boxBlur9(in SAMPLER_TYPE tex, in vec2 st, in vec2 offset) {
#ifdef BOXBLUR_2D
return boxBlur2D_fast9(tex, st, offset);
#else
return boxBlur1D(tex, st, offset, 5);
#endif
}
BOXBLUR_TYPE boxBlur5(in SAMPLER_TYPE tex, in vec2 st, in vec2 offset) {
#ifdef BOXBLUR_2D
return boxBlur2D(tex, st, offset, 3);
#else
return boxBlur1D(tex, st, offset, 3);
#endif
}
BOXBLUR_TYPE boxBlur(in SAMPLER_TYPE tex, in vec2 st, vec2 offset, const int kernelSize) {
#ifdef BOXBLUR_2D
return boxBlur2D(tex, st, offset, kernelSize);
#else
return boxBlur1D(tex, st, offset, kernelSize);
#endif
}
BOXBLUR_TYPE boxBlur(in SAMPLER_TYPE tex, in vec2 st, vec2 offset) {
#ifdef BOXBLUR_2D
return boxBlur2D(tex, st, offset, BOXBLUR_ITERATIONS);
#else
return boxBlur1D(tex, st, offset, BOXBLUR_ITERATIONS);
#endif
}
#endif
Dependencies:
lygia
/sampler
.glsl
lygia
/filter
/boxBlur
/1D
.glsl
lygia
/filter
/boxBlur
/2D
.glsl
lygia
/filter
/boxBlur
/2D_fast9
.glsl
Use:
boxBlur(<SAMPLER_TYPE> texture, <float2> st, <float2> pixel_offset)
#ifndef BOXBLUR_ITERATIONS
#define BOXBLUR_ITERATIONS 3
#endif
#ifndef BOXBLUR_TYPE
#define BOXBLUR_TYPE float4
#endif
#ifndef BOXBLUR_SAMPLER_FNC
#define BOXBLUR_SAMPLER_FNC(TEX, UV) SAMPLER_FNC(TEX, UV)
#endif
#ifndef FNC_BOXBLUR
#define FNC_BOXBLUR
BOXBLUR_TYPE boxBlur13(in SAMPLER_TYPE tex, in float2 st, in float2 offset) {
#ifdef BOXBLUR_2D
return boxBlur2D(tex, st, offset, 7);
#else
return boxBlur1D(tex, st, offset, 7);
#endif
}
BOXBLUR_TYPE boxBlur9(in SAMPLER_TYPE tex, in float2 st, in float2 offset) {
#ifdef BOXBLUR_2D
return boxBlur2D_fast9(tex, st, offset);
#else
return boxBlur1D(tex, st, offset, 5);
#endif
}
BOXBLUR_TYPE boxBlur5(in SAMPLER_TYPE tex, in float2 st, in float2 offset) {
#ifdef BOXBLUR_2D
return boxBlur2D(tex, st, offset, 3);
#else
return boxBlur1D(tex, st, offset, 3);
#endif
}
BOXBLUR_TYPE boxBlur(in SAMPLER_TYPE tex, in float2 st, float2 offset, const int kernelSize) {
#ifdef BOXBLUR_2D
return boxBlur2D(tex, st, offset, kernelSize);
#else
return boxBlur1D(tex, st, offset, kernelSize);
#endif
}
BOXBLUR_TYPE boxBlur(in SAMPLER_TYPE tex, in float2 st, float2 offset) {
#ifdef BOXBLUR_2D
return boxBlur2D(tex, st, offset, BOXBLUR_ITERATIONS);
#else
return boxBlur1D(tex, st, offset, BOXBLUR_ITERATIONS);
#endif
}
#endif
Dependencies:
lygia
/sampler
.glsl
lygia
/filter
/boxBlur
/1D
.glsl
lygia
/filter
/boxBlur
/2D
.glsl
lygia
/filter
/boxBlur
/2D_fast9
.glsl
Use:
boxBlur(<SAMPLER_TYPE> texture, <float2> st, <float2> pixel_offset)
#ifndef BOXBLUR_ITERATIONS
#define BOXBLUR_ITERATIONS 3
#endif
#ifndef BOXBLUR_TYPE
#define BOXBLUR_TYPE float4
#endif
#ifndef BOXBLUR_SAMPLER_FNC
#define BOXBLUR_SAMPLER_FNC(TEX, UV) SAMPLER_FNC(TEX, UV)
#endif
#ifndef FNC_BOXBLUR
#define FNC_BOXBLUR
BOXBLUR_TYPE boxBlur13(SAMPLER_TYPE tex, float2 st, float2 offset) {
#ifdef BOXBLUR_2D
return boxBlur2D(tex, st, offset, 7);
#else
return boxBlur1D(tex, st, offset, 7);
#endif
}
BOXBLUR_TYPE boxBlur9(SAMPLER_TYPE tex, float2 st, float2 offset) {
#ifdef BOXBLUR_2D
return boxBlur2D_fast9(tex, st, offset);
#else
return boxBlur1D(tex, st, offset, 5);
#endif
}
BOXBLUR_TYPE boxBlur5(SAMPLER_TYPE tex, float2 st, float2 offset) {
#ifdef BOXBLUR_2D
return boxBlur2D(tex, st, offset, 3);
#else
return boxBlur1D(tex, st, offset, 3);
#endif
}
BOXBLUR_TYPE boxBlur(SAMPLER_TYPE tex, float2 st, float2 offset, const int kernelSize) {
#ifdef BOXBLUR_2D
return boxBlur2D(tex, st, offset, kernelSize);
#else
return boxBlur1D(tex, st, offset, kernelSize);
#endif
}
BOXBLUR_TYPE boxBlur(SAMPLER_TYPE tex, float2 st, float2 offset) {
#ifdef BOXBLUR_2D
return boxBlur2D(tex, st, offset, BOXBLUR_ITERATIONS);
#else
return boxBlur1D(tex, st, offset, BOXBLUR_ITERATIONS);
#endif
}
#endif
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.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository