Skip to content

Latest commit

 

History

History
75 lines (62 loc) · 1.29 KB

README.md

File metadata and controls

75 lines (62 loc) · 1.29 KB

Glsl loader for webpack

Glsl loader for webpack2 & webpack3. It support chunks & inspire by ShaderLoader

Getting started

Install:

npm install shader-loader --save-dev

Config webpack:

module: {
	rules: [
      {
        test: /\.(glsl|vs|fs)$/,
        loader: 'shader-loader',
        options: {
          glsl: {
            chunkPath: resolve("/glsl/chunks")
          }
        }
      }
	]
}

You can now require your glsl files:

var vertexShader = require("shader.vs");
var fragmentShader = require("shader.fs");

if you use $xxx in your shader its replace by the content of xxx.glsl, for example:

void main(void) {
	$snoise //replace by chunks/snoise.glsl
}

Learn more about loaders & webpack: http://webpack.github.io/docs/loaders.html

Options

chunkPath

Path, where chunks are located

options: {
    glsl: {
        chunkPath: path.resolve(__dirname, "src/glsl/chunks")
    }
}

chunkPrefix

Customize, how import will be look like

options: {
    glsl: {
        chunkPrefix: '#include '
    }
}
void main(void) {
	#include snoise //replace by <path>/snoise.glsl
}

License

MIT (http://www.opensource.org/licenses/mit-license.php)