Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including glslify-import with all npm packages installed. Try it out:

var glslifyImport = require("glslify-import")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

glslify-import v3.1.0

A transform stream for glslify that adds an `import` directive to your shaders.

glslify-import

A transform stream for glslify that adds an import directive to your shaders.

Usage

Given a basic shader:

// main.frag
#pragma glslify: import('./common.glsl')

void main() {
  gl_FragColor = vec4(color, 1.0);
}

You can import ./common.glsl:

// common.glsl
varying vec3 color;

And have the contents inlined into your shader:

varying vec3 color;

void main() {
  gl_FragColor = vec4(color, 1.0);
}

You can also use glslify pragmas and the like from your imported files as well. Useful for the cases when you want to include a common "base" set of definitions in your shaders without losing the niceties of glslify.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free