Skip to content

Instantly share code, notes, and snippets.

@valentincognito
Last active November 5, 2019 08:57
Show Gist options
  • Save valentincognito/d811c4a07601d778e9f38376e09c9550 to your computer and use it in GitHub Desktop.
Save valentincognito/d811c4a07601d778e9f38376e09c9550 to your computer and use it in GitHub Desktop.
//snippet to easily include three.js shader chunks in your custom shaders
replaceThreeChunkFn(a, b) {
return THREE.ShaderChunk[b] + '\n'
}
shaderParse(glsl) {
return glsl.replace(/\/\/\s?chunk\(\s?(\w+)\s?\);/g, this.replaceThreeChunkFn)
}
//https://github.com/mrdoob/three.js/tree/dev/src/renderers/shaders/ShaderChunk
// chunk(shadowmap_vertex);
// chunk(bumpmap_pars_fragment);
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment