glsl-barrel-pincushion

1.0.2 • Public • Published

glsl-barrel-pincushion

stable

Distort the UV with barrel or pincushion effect. Adapted from this shadertoy.

glsl-barrel-pincushion

Installation 📦

npm i glsl-barrel-pincushion -S

Usage 📖

barrelPincushion(vec2 st, float strength)

strength > 0 for barrel distortion, strength < 0 for pincushion.

Example 💾

uniform float uTime;
#pragma glslify: barrelPincushion require(glsl-barrel-pincushion) 
#pragma glslify: rectangle require(glsl-2d-primitives/rectangle) 
 
attribute vec2 vUv;
 
void main() {
    vec2 st = barrelPincushion(vUv, sin(uTime));
    float shape = rectangle(st, vec2(0.5));
    gl_FragColor = vec4(color, shape);
}

Demo

License 📝

MIT. See LICENSE for details.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i glsl-barrel-pincushion

      Weekly Downloads

      6

      Version

      1.0.2

      License

      MIT

      Unpacked Size

      3.11 kB

      Total Files

      4

      Last publish

      Collaborators

      • ayamflow