一覧へ戻る
haiyoucuv/rollup-plugin-glsl-loader(新しいタブで開きます)
主要言語: TypeScript
rollup-plugin-glsl-loader
- star 数
- 2
- watcher 数
- 1
- fork 数
- 0
- issue 数
- 0
- 最終更新
- 2022/05/26
主要言語: TypeScript
rollup-plugin-glsl-loader
import your shader file using ES modules.
import your glsl file using ES modules, like this.
import vert from './shader.vert'; console.log(vert);
Supported file types
*.glsl*.vert/*.frag*.vs/*.fsyarn add rollup-plugin-glsl-loader -D
or
npm i rollup-plugin-glsl-loader -D
const glslLoader = require("rollup-plugin-glsl-loader"); // or use ES modules // import glslLoader from "rollup-plugin-glsl-loader"; export default { // [...], plugins: [ glslLoader(), ] }
You can use include directive.
// 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); }
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); }