Skip to content

Commit fba97af

Browse files
committed
Update dirty uniforms
1 parent f32b4c7 commit fba97af

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

src/renderer/webgl/WebGLShader.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ var WebGLShader = new Class({
7878
bind: function ()
7979
{
8080
this.renderer.setProgram(this.program);
81+
82+
var pipeline = this.pipeline;
83+
84+
if (pipeline.mvpDirty)
85+
{
86+
this.setMatrix4fv('uModelMatrix', false, pipeline.modelMatrix.val);
87+
this.setMatrix4fv('uViewMatrix', false, pipeline.viewMatrix.val);
88+
this.setMatrix4fv('uProjectionMatrix', false, pipeline.projectionMatrix.val);
89+
90+
pipeline.mvpDirty = false;
91+
}
8192
},
8293

8394
/**
@@ -320,7 +331,9 @@ var WebGLShader = new Class({
320331
*/
321332
set1iv: function (name, arr)
322333
{
323-
this.gl.uniform1iv(this.uniforms[name], arr);
334+
// this.gl.uniform1iv(this.uniforms[name], arr);
335+
336+
this.gl.uniform1iv(this.gl.getUniformLocation(this.program, name), arr);
324337

325338
return this;
326339
},
@@ -539,7 +552,9 @@ var WebGLShader = new Class({
539552
*/
540553
setMatrix4fv: function (name, transpose, matrix)
541554
{
542-
this.gl.uniformMatrix4fv(this.uniforms[name], transpose, matrix);
555+
// this.gl.uniformMatrix4fv(this.uniforms[name], transpose, matrix);
556+
557+
this.gl.uniformMatrix4fv(this.gl.getUniformLocation(this.program, name), transpose, matrix);
543558

544559
return this;
545560
}

0 commit comments

Comments
 (0)