A fast blur effect that uses a random hash to compute the sample offset. This gives a snowy/grainy feel to the blur. When requiring, you must specify a
sample function and the
vec3# blur = require('glsl-hash-blur', sample=tex, iterations=20)vec3void
See demo.frag for an implementation of a vignette blur.
The effect was inspired by David Hoskins' ShaderToy.
highp precision for best results on mobile and other low-end devices.
Requires the module with your desired sampling function
S and iteration count
I. The sample function has the following signature:
Using the sample function provided above, this will create a blur using the specified UV coordinates and
radius strength. The radius is typically multiplied by texel size, e.g.
1.0 / resolution.x.
aspect (defaults to 1.0) is recommended to produce a more accurate blur; e.g.
resolution.x / resolution.y.
offset is optional (defaults to 0.0). It offsets the uvs during randomization, which can produce a "jitter" effect like moving film noise.
To build/run the demo from source:
git clone https://github.com/stackgl/glsl-hash-blur.gitcd glsl-hash-blurnpm install
Then run the following to start development:
npm run start
And open http://localhost:9966/. Changes to the file will trigger a LiveReload event on the page.
To run the production build:
npm run build
MIT, see LICENSE.md for details.