Optimized separable gaussian blurs for GLSL. This is adapted from Efficient Gaussian Blur with Linear Sampling.
The function blurs in a single direction. For correct results, the texture should be using
# blur = require('glsl-fast-gaussian-blur')uniform vec2 iResolution;uniform sampler2D iChannel0;uniform vec2 direction;void
The module provides three levels of "taps" (the number of pixels averaged for the blur) that can be required individually. The default is 9.
# blur1 = require('glsl-fast-gaussian-blur/13')# blur2 = require('glsl-fast-gaussian-blur/9')# blur3 = require('glsl-fast-gaussian-blur/5')
npm install glsl-fast-gaussian-blur --save
vec4 blur(sampler2D image, vec2 uv, vec2 resolution, vec2 direction)
image from the specified
uv coordinate, using the given
resolution (size in pixels of screen) and
direction -- typically either
[1, 0] (horizontal) or
[0, 1] (vertical).
Returns the blurred pixel color.
This can be further optimized on some devices (notably PowerVR) by using non-dependent texture reads. This can be done by calculating the texture coordinates in the vertex shader, and passing them as varyings to the fragment shader. This is left as an exercise for the reader to keep this module simple. You can read more about it here.
MIT, see LICENSE.md for details.