Skip to content

yiwenl/glsl-bezier-curve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

glsl-bezier-curve

Bezier curve ported to an NPM package for glslify.

Installation

npm install glsl-bezier-curve

Usage

attribute vec3 position;

uniform mat4 uModelMatrix;
uniform mat4 uViewMatrix;
uniform mat4 uProjectionMatrix;
uniform float uTime;

#pragma glslify: bezier = require(glsl-bezier-curve)

void main() {
  vec3 start    = vec3(2.0, 0.0, 0.0);
  vec3 end      = vec3(-2.0, 0.0, 0.0);
  vec3 control1 = vec3(1.0, 2.0, 0.0);
  vec3 control2 = vec3(-1.0, -2.0, 0.0);
  float time    = fract(uTime * 0.5);

  vec3 posOffset = bezier(start, control1, control2, end, time);
  
  gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(position + posOffset, 1.0);
}

About

GLSL Bezier curve

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages