📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

rollup-plugin-glsl-loader

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-glsl-loader

import your shader file using ES modules.

1.0.13
latest
Source
npm
Version published
Maintainers
1
Created
Source

rollup-plugin-glsl-loader

import your shader file using ES modules.

Do what

import your glsl file using ES modules, like this.

import vert from './shader.vert';

console.log(vert);

Supported file types

  • *.glsl
  • *.vert/*.frag
  • *.vs/*.fs

How to use

Install

yarn add rollup-plugin-glsl-loader -D

or

npm i rollup-plugin-glsl-loader -D

Use in Rollup config file

const glslLoader = require("rollup-plugin-glsl-loader");
// or use ES modules
// import glslLoader from "rollup-plugin-glsl-loader";

export default {
	// [...],
    plugins: [
        glslLoader(),
    ]
}

#include

You can use include directive.

Example:

// defaultAttribute.glsl
attribute vec3 pos;
// vert.glsl
#include "defaultAttribute.glsl"

void main(){

    gl_Position = vec4(pos, 1.0);

}

equivalent to

attribute vec3 pos;

void main(){

    gl_Position = vec4(pos, 1.0);

}

glslify

process glsl file with glslify.

And install glslify in your devDependencies with

npm i glslify -D
yarn add glslify -D

then

const glslLoader = require("rollup-plugin-glsl-loader");
// or use ES modules
// import glslLoader from "rollup-plugin-glsl-loader";

export default {
    // [...],
    plugins: [
        glslLoader({
            glslify: true,
        }),
    ]
}

in your glsl file

#pragma glslify: noise = require('glsl-noise/simplex/3d')

attribute vec3 pos;

void main(){

    gl_Position = vec4(pos, 1.0);

}

Keywords

glsl

FAQs

Package last updated on 04 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts