GLSL snippet for a generic vertex shader for use with glslify
. Includes standard components like model, animate, view, and projection matrices. Designed for standalone use. You might find it useful if you find yourself writing this boilerplate shader, or something similar, a lot.
Add to your project with
npm install glsl-basic-vertex-shader
Inside your vertex shader just call
#pragma glslify: main = require('glsl-basic-vertex-shader')
Make sure you define all attributes
and uniforms
. If you don't need to use any of the matrices just set them to the identity matrix. The varying
variables can be used in your fragment shader.
vec3
position
input vertex positionvec3
normal
input vertex normal
mat4
projection
projection matrixmat4
view
view matrixmat4
model
model matrixmat4
animate
animation matrixmat3
modelNormal
transpose inverse of model matrixmat3
animateNormal
transpose inverse of animation matrix
vec3
vposition
computed vertex positionvec3
vnormal
computed vertex normal