diff --git a/src/core/renderers/webgl/systems/geometry/GeometrySystem.js b/src/core/renderers/webgl/systems/geometry/GeometrySystem.js index ef7570c..b07837f 100644 --- a/src/core/renderers/webgl/systems/geometry/GeometrySystem.js +++ b/src/core/renderers/webgl/systems/geometry/GeometrySystem.js @@ -45,8 +45,11 @@ */ bind(geometry, glShader) { + glShader = glShader || this.renderer.shader.getGLShader(); + const gl = this.gl; + // not sure the best way to address this.. // currently different shaders require different VAOs for the same geometry // Still mulling over the best way to solve this one.. diff --git a/src/core/renderers/webgl/systems/geometry/GeometrySystem.js b/src/core/renderers/webgl/systems/geometry/GeometrySystem.js index ef7570c..b07837f 100644 --- a/src/core/renderers/webgl/systems/geometry/GeometrySystem.js +++ b/src/core/renderers/webgl/systems/geometry/GeometrySystem.js @@ -45,8 +45,11 @@ */ bind(geometry, glShader) { + glShader = glShader || this.renderer.shader.getGLShader(); + const gl = this.gl; + // not sure the best way to address this.. // currently different shaders require different VAOs for the same geometry // Still mulling over the best way to solve this one.. diff --git a/src/core/shader/Program.js b/src/core/shader/Program.js index ac37001..c5d09cd 100644 --- a/src/core/shader/Program.js +++ b/src/core/shader/Program.js @@ -142,6 +142,8 @@ { const uniformData = gl.getActiveUniform(program, i); const name = uniformData.name.replace(/\[.*?\]/, ''); + + const isArray = uniformData.name.match(/\[.*?\]/, ''); const type = shaderUtils.mapType(gl, uniformData.type); // if (!name.match(maskRegex)) @@ -150,6 +152,7 @@ uniforms[name] = { type: type, size: uniformData.size, + isArray:isArray, value: shaderUtils.defaultValue(type, uniformData.size), }; /*eslint-enable */ diff --git a/src/core/renderers/webgl/systems/geometry/GeometrySystem.js b/src/core/renderers/webgl/systems/geometry/GeometrySystem.js index ef7570c..b07837f 100644 --- a/src/core/renderers/webgl/systems/geometry/GeometrySystem.js +++ b/src/core/renderers/webgl/systems/geometry/GeometrySystem.js @@ -45,8 +45,11 @@ */ bind(geometry, glShader) { + glShader = glShader || this.renderer.shader.getGLShader(); + const gl = this.gl; + // not sure the best way to address this.. // currently different shaders require different VAOs for the same geometry // Still mulling over the best way to solve this one.. diff --git a/src/core/shader/Program.js b/src/core/shader/Program.js index ac37001..c5d09cd 100644 --- a/src/core/shader/Program.js +++ b/src/core/shader/Program.js @@ -142,6 +142,8 @@ { const uniformData = gl.getActiveUniform(program, i); const name = uniformData.name.replace(/\[.*?\]/, ''); + + const isArray = uniformData.name.match(/\[.*?\]/, ''); const type = shaderUtils.mapType(gl, uniformData.type); // if (!name.match(maskRegex)) @@ -150,6 +152,7 @@ uniforms[name] = { type: type, size: uniformData.size, + isArray:isArray, value: shaderUtils.defaultValue(type, uniformData.size), }; /*eslint-enable */ diff --git a/src/core/shader/Shader.js b/src/core/shader/Shader.js index ad4fcfc..426baa6 100644 --- a/src/core/shader/Shader.js +++ b/src/core/shader/Shader.js @@ -40,19 +40,46 @@ // does the trick for now though! for (const i in program.uniformData) { - const uniform = this.uniformGroup.uniforms[i]; + const exists = this.checkUniformExists(i, this.uniformGroup);//this.uniformGroup.uniforms[i]; - if (!uniform) // bad as we need check wher ethe uniforms are.. + if (!exists) // bad as we need check wher ethe uniforms are.. { - //this.uniformGroup.uniforms[i] = program.uniformData[i].value; + //console.log("uniform does not exist " + i) + // search within other groups to find the property + // failing that, create it on the root uniform object + this.uniformGroup.uniforms[i] = program.uniformData[i].value; + } - else if (uniform instanceof Array) + else if (this.uniformGroup.uniforms[i] instanceof Array) { this.uniformGroup.uniforms[i] = new Float32Array(uniform); } } } + checkUniformExists(name, group) + { + if(group.uniforms[name]) + { + return true; + } + + for (const i in group.uniforms) + { + const uniform = group.uniforms[i]; + + if(uniform.group) + { + if( this.checkUniformExists(name, uniform) ) + { + return true; + } + } + } + + return false; + } + get uniforms() { return this.uniformGroup.uniforms; diff --git a/src/core/renderers/webgl/systems/geometry/GeometrySystem.js b/src/core/renderers/webgl/systems/geometry/GeometrySystem.js index ef7570c..b07837f 100644 --- a/src/core/renderers/webgl/systems/geometry/GeometrySystem.js +++ b/src/core/renderers/webgl/systems/geometry/GeometrySystem.js @@ -45,8 +45,11 @@ */ bind(geometry, glShader) { + glShader = glShader || this.renderer.shader.getGLShader(); + const gl = this.gl; + // not sure the best way to address this.. // currently different shaders require different VAOs for the same geometry // Still mulling over the best way to solve this one.. diff --git a/src/core/shader/Program.js b/src/core/shader/Program.js index ac37001..c5d09cd 100644 --- a/src/core/shader/Program.js +++ b/src/core/shader/Program.js @@ -142,6 +142,8 @@ { const uniformData = gl.getActiveUniform(program, i); const name = uniformData.name.replace(/\[.*?\]/, ''); + + const isArray = uniformData.name.match(/\[.*?\]/, ''); const type = shaderUtils.mapType(gl, uniformData.type); // if (!name.match(maskRegex)) @@ -150,6 +152,7 @@ uniforms[name] = { type: type, size: uniformData.size, + isArray:isArray, value: shaderUtils.defaultValue(type, uniformData.size), }; /*eslint-enable */ diff --git a/src/core/shader/Shader.js b/src/core/shader/Shader.js index ad4fcfc..426baa6 100644 --- a/src/core/shader/Shader.js +++ b/src/core/shader/Shader.js @@ -40,19 +40,46 @@ // does the trick for now though! for (const i in program.uniformData) { - const uniform = this.uniformGroup.uniforms[i]; + const exists = this.checkUniformExists(i, this.uniformGroup);//this.uniformGroup.uniforms[i]; - if (!uniform) // bad as we need check wher ethe uniforms are.. + if (!exists) // bad as we need check wher ethe uniforms are.. { - //this.uniformGroup.uniforms[i] = program.uniformData[i].value; + //console.log("uniform does not exist " + i) + // search within other groups to find the property + // failing that, create it on the root uniform object + this.uniformGroup.uniforms[i] = program.uniformData[i].value; + } - else if (uniform instanceof Array) + else if (this.uniformGroup.uniforms[i] instanceof Array) { this.uniformGroup.uniforms[i] = new Float32Array(uniform); } } } + checkUniformExists(name, group) + { + if(group.uniforms[name]) + { + return true; + } + + for (const i in group.uniforms) + { + const uniform = group.uniforms[i]; + + if(uniform.group) + { + if( this.checkUniformExists(name, uniform) ) + { + return true; + } + } + } + + return false; + } + get uniforms() { return this.uniformGroup.uniforms; diff --git a/src/core/shader/generateUniformsSync2.js b/src/core/shader/generateUniformsSync2.js index 8a0fd6b..a643add 100644 --- a/src/core/shader/generateUniformsSync2.js +++ b/src/core/shader/generateUniformsSync2.js @@ -76,7 +76,7 @@ { const data = uniformData[i]; //group.uniforms[i]; - // console.log(i, data); + //console.log(i, data); if(!data) { if(group.uniforms[i].group) @@ -98,7 +98,7 @@ gl.uniform1f(uniformData.${i}.location, uniformValues.${i}) }\n`; } - else if ( (data.type === 'sampler2D' || data.type === 'samplerCube' || data.type === 'sampler2DArray') && data.size === 1) + else if ( (data.type === 'sampler2D' || data.type === 'samplerCube' || data.type === 'sampler2DArray') && data.size === 1 && !data.isArray) { func += `\nif (uniformValues.${i}.baseTexture) { @@ -183,8 +183,8 @@ } } - console.log(' --------------- ') - console.log(func); + //console.log(' --------------- ') + // console.log(func); return new Function('uniformData', 'uniformValues', 'renderer', func); // eslint-disable-line no-new-func } diff --git a/src/core/renderers/webgl/systems/geometry/GeometrySystem.js b/src/core/renderers/webgl/systems/geometry/GeometrySystem.js index ef7570c..b07837f 100644 --- a/src/core/renderers/webgl/systems/geometry/GeometrySystem.js +++ b/src/core/renderers/webgl/systems/geometry/GeometrySystem.js @@ -45,8 +45,11 @@ */ bind(geometry, glShader) { + glShader = glShader || this.renderer.shader.getGLShader(); + const gl = this.gl; + // not sure the best way to address this.. // currently different shaders require different VAOs for the same geometry // Still mulling over the best way to solve this one.. diff --git a/src/core/shader/Program.js b/src/core/shader/Program.js index ac37001..c5d09cd 100644 --- a/src/core/shader/Program.js +++ b/src/core/shader/Program.js @@ -142,6 +142,8 @@ { const uniformData = gl.getActiveUniform(program, i); const name = uniformData.name.replace(/\[.*?\]/, ''); + + const isArray = uniformData.name.match(/\[.*?\]/, ''); const type = shaderUtils.mapType(gl, uniformData.type); // if (!name.match(maskRegex)) @@ -150,6 +152,7 @@ uniforms[name] = { type: type, size: uniformData.size, + isArray:isArray, value: shaderUtils.defaultValue(type, uniformData.size), }; /*eslint-enable */ diff --git a/src/core/shader/Shader.js b/src/core/shader/Shader.js index ad4fcfc..426baa6 100644 --- a/src/core/shader/Shader.js +++ b/src/core/shader/Shader.js @@ -40,19 +40,46 @@ // does the trick for now though! for (const i in program.uniformData) { - const uniform = this.uniformGroup.uniforms[i]; + const exists = this.checkUniformExists(i, this.uniformGroup);//this.uniformGroup.uniforms[i]; - if (!uniform) // bad as we need check wher ethe uniforms are.. + if (!exists) // bad as we need check wher ethe uniforms are.. { - //this.uniformGroup.uniforms[i] = program.uniformData[i].value; + //console.log("uniform does not exist " + i) + // search within other groups to find the property + // failing that, create it on the root uniform object + this.uniformGroup.uniforms[i] = program.uniformData[i].value; + } - else if (uniform instanceof Array) + else if (this.uniformGroup.uniforms[i] instanceof Array) { this.uniformGroup.uniforms[i] = new Float32Array(uniform); } } } + checkUniformExists(name, group) + { + if(group.uniforms[name]) + { + return true; + } + + for (const i in group.uniforms) + { + const uniform = group.uniforms[i]; + + if(uniform.group) + { + if( this.checkUniformExists(name, uniform) ) + { + return true; + } + } + } + + return false; + } + get uniforms() { return this.uniformGroup.uniforms; diff --git a/src/core/shader/generateUniformsSync2.js b/src/core/shader/generateUniformsSync2.js index 8a0fd6b..a643add 100644 --- a/src/core/shader/generateUniformsSync2.js +++ b/src/core/shader/generateUniformsSync2.js @@ -76,7 +76,7 @@ { const data = uniformData[i]; //group.uniforms[i]; - // console.log(i, data); + //console.log(i, data); if(!data) { if(group.uniforms[i].group) @@ -98,7 +98,7 @@ gl.uniform1f(uniformData.${i}.location, uniformValues.${i}) }\n`; } - else if ( (data.type === 'sampler2D' || data.type === 'samplerCube' || data.type === 'sampler2DArray') && data.size === 1) + else if ( (data.type === 'sampler2D' || data.type === 'samplerCube' || data.type === 'sampler2DArray') && data.size === 1 && !data.isArray) { func += `\nif (uniformValues.${i}.baseTexture) { @@ -183,8 +183,8 @@ } } - console.log(' --------------- ') - console.log(func); + //console.log(' --------------- ') + // console.log(func); return new Function('uniformData', 'uniformValues', 'renderer', func); // eslint-disable-line no-new-func } diff --git a/src/core/sprites/webgl/SpriteRenderer.js b/src/core/sprites/webgl/SpriteRenderer.js index d5f644f..dc9d8bf 100644 --- a/src/core/sprites/webgl/SpriteRenderer.js +++ b/src/core/sprites/webgl/SpriteRenderer.js @@ -9,6 +9,7 @@ import bitTwiddle from 'bit-twiddle'; import Geometry from '../../geometry/Geometry'; import Buffer_GEOM from '../../geometry/Buffer'; +import UniformGroup from '../../shader/UniformGroup'; let TICK = 0; let TEXTURE_TICK = 0; @@ -105,7 +106,7 @@ { const gl = this.renderer.gl; - if (this.renderer.legacy) + if (true)//this.renderer.legacy) { this.MAX_TEXTURES = 1; } @@ -118,8 +119,6 @@ this.MAX_TEXTURES = checkMaxIfStatmentsInShader(this.MAX_TEXTURES, gl); } - const shader = this.shader = generateMultiTextureShader(gl, this.MAX_TEXTURES); - const sampleValues = new Int32Array(this.MAX_TEXTURES); for (let i = 0; i < this.MAX_TEXTURES; i++) @@ -127,8 +126,13 @@ sampleValues[i] = i; } - shader.uniformGroup.add('default', {uSamplers:sampleValues}, true);//this.renderer.globalUniforms; - shader.uniforms.globals = this.renderer.globalUniforms; + const uniforms = { + default:UniformGroup.from({uSamplers:sampleValues}, true), + globals:this.renderer.globalUniforms + } + + // generate generateMultiTextureProgram, may be a better move? + this.shader = generateMultiTextureShader(gl, this.MAX_TEXTURES, uniforms); // we use the second shader as the first one depending on your browser may omit aTextureId // as it is not used by the shader so is optimized out. @@ -350,31 +354,23 @@ if (this.vaoMax <= this.vertexCount) { this.vaoMax++; - this.vertexBuffers[this.vertexCount] = GLBuffer.createVertexBuffer(gl, null, gl.DYNAMIC_DRAW); + + let buffer = new Buffer_GEOM(null, false); /* eslint-disable max-len */ - - var attributeData = this.shader.program.attributeData; - - // build the vao object that will render.. - this.vaos[this.vertexCount] = this.renderer.geometry.createVao() - .addIndex(this.indexBuffer) - .addAttribute(this.vertexBuffers[this.vertexCount], attributeData.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0) - .addAttribute(this.vertexBuffers[this.vertexCount], attributeData.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) - .addAttribute(this.vertexBuffers[this.vertexCount], attributeData.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4); - - - if (attributeData.aTextureId) - { - this.vaos[this.vertexCount].addAttribute(this.vertexBuffers[this.vertexCount], attributeData.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); - } - + this.vaos[this.vertexCount] = new Geometry() + .addAttribute('aVertexPosition', buffer, 2, false, gl.FLOAT) + .addAttribute('aTextureCoord', buffer, 2, true, gl.UNSIGNED_SHORT) + .addAttribute('aColor', buffer, 4, true, gl.UNSIGNED_BYTE) + .addAttribute('aTextureId', buffer, 1, true, gl.FLOAT) + .addIndex(this.indexBuffer) /* eslint-enable max-len */ + + this.vertexBuffers[this.vertexCount] = buffer; } - this.renderer.geometry.bindVao(this.vaos[this.vertexCount]); - - this.vertexBuffers[this.vertexCount].upload(buffer.vertices, 0, false); + this.vertexBuffers[this.vertexCount].update(buffer.vertices, 0); + this.renderer.geometry.bind(this.vaos[this.vertexCount]); this.vertexCount++; } @@ -412,14 +408,12 @@ */ start() { - // this.renderer._bindGLShader(this.shader); - const glShader = this.renderer.shader.bind(this.shader, true); - this.renderer.shader.syncUniformGroup(this.shader.uniformGroup); + this.renderer.shader.bind(this.shader); if (settings.CAN_UPLOAD_SAME_BUFFER) { // bind buffer #0, we don't need others - this.renderer.geometry.bind(this.vaos[this.vertexCount], glShader); + this.renderer.geometry.bind(this.vaos[this.vertexCount]); } } diff --git a/src/core/renderers/webgl/systems/geometry/GeometrySystem.js b/src/core/renderers/webgl/systems/geometry/GeometrySystem.js index ef7570c..b07837f 100644 --- a/src/core/renderers/webgl/systems/geometry/GeometrySystem.js +++ b/src/core/renderers/webgl/systems/geometry/GeometrySystem.js @@ -45,8 +45,11 @@ */ bind(geometry, glShader) { + glShader = glShader || this.renderer.shader.getGLShader(); + const gl = this.gl; + // not sure the best way to address this.. // currently different shaders require different VAOs for the same geometry // Still mulling over the best way to solve this one.. diff --git a/src/core/shader/Program.js b/src/core/shader/Program.js index ac37001..c5d09cd 100644 --- a/src/core/shader/Program.js +++ b/src/core/shader/Program.js @@ -142,6 +142,8 @@ { const uniformData = gl.getActiveUniform(program, i); const name = uniformData.name.replace(/\[.*?\]/, ''); + + const isArray = uniformData.name.match(/\[.*?\]/, ''); const type = shaderUtils.mapType(gl, uniformData.type); // if (!name.match(maskRegex)) @@ -150,6 +152,7 @@ uniforms[name] = { type: type, size: uniformData.size, + isArray:isArray, value: shaderUtils.defaultValue(type, uniformData.size), }; /*eslint-enable */ diff --git a/src/core/shader/Shader.js b/src/core/shader/Shader.js index ad4fcfc..426baa6 100644 --- a/src/core/shader/Shader.js +++ b/src/core/shader/Shader.js @@ -40,19 +40,46 @@ // does the trick for now though! for (const i in program.uniformData) { - const uniform = this.uniformGroup.uniforms[i]; + const exists = this.checkUniformExists(i, this.uniformGroup);//this.uniformGroup.uniforms[i]; - if (!uniform) // bad as we need check wher ethe uniforms are.. + if (!exists) // bad as we need check wher ethe uniforms are.. { - //this.uniformGroup.uniforms[i] = program.uniformData[i].value; + //console.log("uniform does not exist " + i) + // search within other groups to find the property + // failing that, create it on the root uniform object + this.uniformGroup.uniforms[i] = program.uniformData[i].value; + } - else if (uniform instanceof Array) + else if (this.uniformGroup.uniforms[i] instanceof Array) { this.uniformGroup.uniforms[i] = new Float32Array(uniform); } } } + checkUniformExists(name, group) + { + if(group.uniforms[name]) + { + return true; + } + + for (const i in group.uniforms) + { + const uniform = group.uniforms[i]; + + if(uniform.group) + { + if( this.checkUniformExists(name, uniform) ) + { + return true; + } + } + } + + return false; + } + get uniforms() { return this.uniformGroup.uniforms; diff --git a/src/core/shader/generateUniformsSync2.js b/src/core/shader/generateUniformsSync2.js index 8a0fd6b..a643add 100644 --- a/src/core/shader/generateUniformsSync2.js +++ b/src/core/shader/generateUniformsSync2.js @@ -76,7 +76,7 @@ { const data = uniformData[i]; //group.uniforms[i]; - // console.log(i, data); + //console.log(i, data); if(!data) { if(group.uniforms[i].group) @@ -98,7 +98,7 @@ gl.uniform1f(uniformData.${i}.location, uniformValues.${i}) }\n`; } - else if ( (data.type === 'sampler2D' || data.type === 'samplerCube' || data.type === 'sampler2DArray') && data.size === 1) + else if ( (data.type === 'sampler2D' || data.type === 'samplerCube' || data.type === 'sampler2DArray') && data.size === 1 && !data.isArray) { func += `\nif (uniformValues.${i}.baseTexture) { @@ -183,8 +183,8 @@ } } - console.log(' --------------- ') - console.log(func); + //console.log(' --------------- ') + // console.log(func); return new Function('uniformData', 'uniformValues', 'renderer', func); // eslint-disable-line no-new-func } diff --git a/src/core/sprites/webgl/SpriteRenderer.js b/src/core/sprites/webgl/SpriteRenderer.js index d5f644f..dc9d8bf 100644 --- a/src/core/sprites/webgl/SpriteRenderer.js +++ b/src/core/sprites/webgl/SpriteRenderer.js @@ -9,6 +9,7 @@ import bitTwiddle from 'bit-twiddle'; import Geometry from '../../geometry/Geometry'; import Buffer_GEOM from '../../geometry/Buffer'; +import UniformGroup from '../../shader/UniformGroup'; let TICK = 0; let TEXTURE_TICK = 0; @@ -105,7 +106,7 @@ { const gl = this.renderer.gl; - if (this.renderer.legacy) + if (true)//this.renderer.legacy) { this.MAX_TEXTURES = 1; } @@ -118,8 +119,6 @@ this.MAX_TEXTURES = checkMaxIfStatmentsInShader(this.MAX_TEXTURES, gl); } - const shader = this.shader = generateMultiTextureShader(gl, this.MAX_TEXTURES); - const sampleValues = new Int32Array(this.MAX_TEXTURES); for (let i = 0; i < this.MAX_TEXTURES; i++) @@ -127,8 +126,13 @@ sampleValues[i] = i; } - shader.uniformGroup.add('default', {uSamplers:sampleValues}, true);//this.renderer.globalUniforms; - shader.uniforms.globals = this.renderer.globalUniforms; + const uniforms = { + default:UniformGroup.from({uSamplers:sampleValues}, true), + globals:this.renderer.globalUniforms + } + + // generate generateMultiTextureProgram, may be a better move? + this.shader = generateMultiTextureShader(gl, this.MAX_TEXTURES, uniforms); // we use the second shader as the first one depending on your browser may omit aTextureId // as it is not used by the shader so is optimized out. @@ -350,31 +354,23 @@ if (this.vaoMax <= this.vertexCount) { this.vaoMax++; - this.vertexBuffers[this.vertexCount] = GLBuffer.createVertexBuffer(gl, null, gl.DYNAMIC_DRAW); + + let buffer = new Buffer_GEOM(null, false); /* eslint-disable max-len */ - - var attributeData = this.shader.program.attributeData; - - // build the vao object that will render.. - this.vaos[this.vertexCount] = this.renderer.geometry.createVao() - .addIndex(this.indexBuffer) - .addAttribute(this.vertexBuffers[this.vertexCount], attributeData.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0) - .addAttribute(this.vertexBuffers[this.vertexCount], attributeData.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) - .addAttribute(this.vertexBuffers[this.vertexCount], attributeData.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4); - - - if (attributeData.aTextureId) - { - this.vaos[this.vertexCount].addAttribute(this.vertexBuffers[this.vertexCount], attributeData.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); - } - + this.vaos[this.vertexCount] = new Geometry() + .addAttribute('aVertexPosition', buffer, 2, false, gl.FLOAT) + .addAttribute('aTextureCoord', buffer, 2, true, gl.UNSIGNED_SHORT) + .addAttribute('aColor', buffer, 4, true, gl.UNSIGNED_BYTE) + .addAttribute('aTextureId', buffer, 1, true, gl.FLOAT) + .addIndex(this.indexBuffer) /* eslint-enable max-len */ + + this.vertexBuffers[this.vertexCount] = buffer; } - this.renderer.geometry.bindVao(this.vaos[this.vertexCount]); - - this.vertexBuffers[this.vertexCount].upload(buffer.vertices, 0, false); + this.vertexBuffers[this.vertexCount].update(buffer.vertices, 0); + this.renderer.geometry.bind(this.vaos[this.vertexCount]); this.vertexCount++; } @@ -412,14 +408,12 @@ */ start() { - // this.renderer._bindGLShader(this.shader); - const glShader = this.renderer.shader.bind(this.shader, true); - this.renderer.shader.syncUniformGroup(this.shader.uniformGroup); + this.renderer.shader.bind(this.shader); if (settings.CAN_UPLOAD_SAME_BUFFER) { // bind buffer #0, we don't need others - this.renderer.geometry.bind(this.vaos[this.vertexCount], glShader); + this.renderer.geometry.bind(this.vaos[this.vertexCount]); } } diff --git a/src/core/sprites/webgl/generateMultiTextureShader.js b/src/core/sprites/webgl/generateMultiTextureShader.js index 1dabb7a..0d555ce 100644 --- a/src/core/sprites/webgl/generateMultiTextureShader.js +++ b/src/core/sprites/webgl/generateMultiTextureShader.js @@ -18,7 +18,7 @@ '}', ].join('\n'); -export default function generateMultiTextureShader(gl, maxTextures) +export default function generateMultiTextureShader(gl, maxTextures, uniforms) { const vertexSrc = readFileSync(join(__dirname, './texture.vert'), 'utf8'); let fragmentSrc = fragTemplate; @@ -27,7 +27,7 @@ fragmentSrc = fragmentSrc.replace(/%forloop%/gi, generateSampleSrc(maxTextures)); const shaderold = new GLShader(gl, vertexSrc, fragmentSrc, PRECISION.DEFAULT); - const shader = Shader.from(vertexSrc, fragmentSrc);//, PRECISION.DEFAULT); + const shader = Shader.from(vertexSrc, fragmentSrc, uniforms);//, PRECISION.DEFAULT); const sampleValues = [];