6 ms·
Looks nice. I had the problem of modularizing GLSL code myself and ended up writing a Require.js plugin which supported #include statements. Take a look at the
by pheelicks 12y ago
Looks nice.
I had the problem of modularizing GLSL code myself and ended up writing a Require.js plugin which supported #include statements. Take a look at the shaders in here if interested: https://github.com/felixpalmer/lod-terrain/tree/master/js/shaders https://github.com/felixpalmer/lod-terrain/tree/master/js/sh... and https://github.com/felixpalmer/amd-three.js/blob/master/js/lib/shader.js https://github.com/felixpalmer/amd-three.js/blob/master/js/l...
While glsify has a bunch of nice features that my plugin lacks, one thing mine can do which (as far as I know) glsify cannot, is provide support for redefining #define statements from JavaScript. I find this quite useful if I need to have several similar shaders and want to tweak their behavior from JavaScript. Something like (see https://github.com/felixpalmer/amd-three.js/blob/master/js/app/material.js https://github.com/felixpalmer/amd-three.js/blob/master/js/a...):
define( ["shader!simple.vert"], function ( simpleVert ) {
simpleFrag.define( "faceColor", "vec3(1.0, 0, 0)" );
var vertexShader = simpleVert.value;
} );
Do you have any thoughts on this feature, or even plans to support something like this in the future?
- mattdesl 12y agoCool, I'll check it out. I don't think it supports anything like that yet. There is some talk about using glslify at runtime, to build "uber shaders" depending on particular needs, and it seems like this kind of feature would be nice.