
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
browserify-shader
Advanced tools
super simple browserify transform for loading webgl shaders
npm install browserify-shader --save
Simply use require()
to load your shader files:
var vs = require('./vertex.c');
var fs = require('./fragment.c');
var vs = require('./vertex.c');
var fs = require('./fragment.c');
var shader = gl.createShader(gl.VERTEX_SHADER)
gl.shaderSource(shader, vs());
gl.compileShader(shader);
gl.attachShader(yourWebGLProg, shader);
var vs = require('./vertex.c');
var fs = require('./fragment.c');
var myMaterial = new THREE.ShaderMaterial({
uniforms: uniforms,
attributes: attributes,
vertexShader: vs(),
fragmentShader: fs(),
transparent: true,
side: THREE.BackSide
});
You can add compile-time parameters in your shaders.
Simply add {{foo}}
-style parameters, eg.:
attribute vec3 pos;
void main() {
gl_Position = vec4(pos, {{zoom}});
}
Then in your code:
var vs = require('./vertex.c');
...
gl.shaderSource(shader, vs({
zoom: "2.0"
}));
For runtime parameters, use uniform
-s in the shader.
browserify-shader recognises the following extensions by default:
[
"c"
, "glsl"
, "vert"
, "frag"
, "vs"
, "fs"
, "gs"
, "vsh"
, "fsh"
, "gsh"
, "vshader"
, "fshader"
, "gshader"
];
You can add/delete/modify this list using:
require("browserify-shader").extensions = ["vertexshader", "fragmentshader", "c"]
The following options will work if you want to customize your transform:
run browserify with the transform option:
browserify -t browserify-shader entry-point.js
browserify -t [browserify-shader --parameterize=true] entry-point.js
When compiling using Javascript code custom extensions can be set:
var browserify = require("browserify");
var browserifyShader = require("browserify-shader")
browserify("./index.js");
.transform(browserifyShader, {
module: "es6"
});
.bundle()
.pipe(fs.createWriteStream("./bundle.js"));
var gulp = require('gulp')
var source = require('vinyl-source-stream')
gulp.task('watch', function() {
var bundler = watchify('./src/index.js');
bundler.transform('browserify-shader')
bundler.on('update', rebundle)
function rebundle () {
return bundler.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('./dist'))
}
return rebundle()
})
FAQs
Super simple WebGL shader loader plugin for browserify
The npm package browserify-shader receives a total of 17 weekly downloads. As such, browserify-shader popularity was classified as not popular.
We found that browserify-shader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.