Skip to content

ayamflow/glsl-barrel-pincushion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

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.

About

Distort UV using barrel or pincushion

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages