1 | # glslify-import #
|
2 |
|
3 | A transform stream for [glslify](http://github.com/stackgl/glslify)
|
4 | that adds an `import` directive to your shaders.
|
5 |
|
6 | ## Usage ##
|
7 |
|
8 | Given a basic shader:
|
9 |
|
10 | ``` glsl
|
11 | // main.frag
|
12 | #pragma glslify: import('./common.glsl')
|
13 |
|
14 | void main() {
|
15 | gl_FragColor = vec4(color, 1.0);
|
16 | }
|
17 | ```
|
18 |
|
19 | You can import `./common.glsl`:
|
20 |
|
21 | ``` glsl
|
22 | // common.glsl
|
23 | varying vec3 color;
|
24 | ```
|
25 |
|
26 | And have the contents inlined into your shader:
|
27 |
|
28 | ``` glsl
|
29 | varying vec3 color;
|
30 |
|
31 | void main() {
|
32 | gl_FragColor = vec4(color, 1.0);
|
33 | }
|
34 | ```
|
35 |
|
36 | You can also use glslify pragmas and the like from your imported files as well.
|
37 | Useful for the cases when you want to include a common "base" set of
|
38 | definitions in your shaders without losing the niceties of glslify.
|