Shakes out any unused functions from your GLSL shaders. Especially useful alongside tools such as glslify.
This is done by running through your shader and checking that each function is actually called. This even works with functions that share the same name but use a different number of arguments! For example, take the following shader:
precision mediump float;floatfloatfloatvoid
After running it through
glsl-token-function-shaker, you should get something like this in return:
precision mediump float;floatvoid
This keeps the size of your shaders down, but can also be used to cut out errors in unused functions.
glsl-token-function-shaker using npm:
npm install --save glsl-token-function-shaker
Takes an array of
tokens from glsl-tokenizer and removes unused functions. Accepts the following options:
ignore: an array of strings containing the names of functions you'd like to keep in the shader, even if they're not being used.
void main();is always preserved, as is the last function in the shader.
tokens array in place, and returns some simple stats:
functionsRemoved: the number of function declarations removed.
tokensRemoved: the number of GLSL tokens removed.
iterations: the number of function shaking iterations made.
const shake =const stringify =const tokenize =const fs =const src = fsconst tokens =const shaken =
MIT, see LICENSE.md for details.