Hi all,
I’m using a file ShaderLoader, which I believe loads up a whole directory of glsl, then you can apply these. However, I’m not currently waiting on this, hence when I use it my shaders are empty!
Hence I’ve love to know how I can upload a .glsl
file more instantaneously. This is how i’m currently doing it:
var shaders = new ShaderLoader("shaders", "shaders");
// For title
shaders.load("global/vs-title", "title", "vertex");
shaders.load("global/fs-title", "title", "fragment");
loader = new Loader();
shaders.shaderSetLoaded = function () {
loader.onLoad();
};
console.log('shader-title', shaders);
console.log('shader vertex', shaders.vertexShaders);
console.log('shader vertex title', shaders.vertexShaders.title);
var titleMat = new THREE.ShaderMaterial({
uniforms: uniforms,
transparent: true,
vertexShader: shaders.vertexShaders.title,
fragmentShader: shaders.fragmentShaders.title
});
If you run this code, you’ll note from the console, shaders.vertextShaders.title
is undefined when using console.log
, but accessing the object directly does show it is present - assume this is due to the delay.
For full code, please checkout: