Skip to content

Commit d00e9c6

Browse files
committed
Add the uModelViewProjectionMatrix uniform.
1 parent f36d825 commit d00e9c6

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/webgl/p5.Shader.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,13 @@ p5.Shader.prototype.unbindTextures = function() {
261261
};
262262

263263
p5.Shader.prototype._setMatrixUniforms = function() {
264-
this.setUniform('uProjectionMatrix', this._renderer.uPMatrix.mat4);
264+
const viewMatrix = this._renderer._curCamera.cameraMatrix;
265+
const projectionMatrix = this._renderer.uPMatrix;
266+
const modelViewMatrix = this._renderer.uMVMatrix;
267+
268+
const modelViewProjectionMatrix = modelViewMatrix.copy();
269+
modelViewProjectionMatrix.mult(projectionMatrix);
270+
265271
if (this.isStrokeShader()) {
266272
if (this._renderer._curCamera.cameraType === 'default') {
267273
// strokes scale up as they approach camera, default
@@ -271,8 +277,10 @@ p5.Shader.prototype._setMatrixUniforms = function() {
271277
this.setUniform('uPerspective', 0);
272278
}
273279
}
274-
this.setUniform('uModelViewMatrix', this._renderer.uMVMatrix.mat4);
275-
this.setUniform('uViewMatrix', this._renderer._curCamera.cameraMatrix.mat4);
280+
this.setUniform('uViewMatrix', viewMatrix.mat4);
281+
this.setUniform('uProjectionMatrix', projectionMatrix.mat4);
282+
this.setUniform('uModelViewMatrix', modelViewMatrix.mat4);
283+
this.setUniform('uModelViewProjectionMatrix', modelViewProjectionMatrix.mat4);
276284
if (this.uniforms.uNormalMatrix) {
277285
this._renderer.uNMatrix.inverseTranspose(this._renderer.uMVMatrix);
278286
this.setUniform('uNormalMatrix', this._renderer.uNMatrix.mat3);

0 commit comments

Comments
 (0)