Skip to content

Commit

Permalink
Chore: Add docs for MV matrix updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Farhad Ghayour committed Jun 19, 2015
1 parent 244494f commit 88313b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions webgl-renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,10 @@ WebGLRenderer.prototype.drawMeshes = function drawMeshes(renderState) {

if (mesh.options) this.handleOptions(mesh.options, mesh);

// Model View Matrix from View Matrix multipled by the Mesh transform
mat44.multiply(meshTransforms.values[0], renderState.viewTransform, mesh.uniformValues[1]);

// Normal Matrix calculated from the Model View Matrix
mat33.normalFromMat4(meshTransforms.values[1], mesh.uniformValues[1]);

this.program.setUniforms(mesh.uniformKeys, mesh.uniformValues);
Expand Down
4 changes: 3 additions & 1 deletion webgl-shaders/VertexShader.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ void main() {
vec3 offsetPos,
invertedNormals;

v_textureCoordinate = a_texCoord;
v_normal = a_normals;
v_textureCoordinate = a_texCoord;

offsetPos = (u_positionOffset.x < 0.0) ? a_pos + calculateOffset(u_positionOffset) : a_pos;
offsetPos = clipSpacePos(offsetPos);
mvPos = u_mvMatrix * vec4(offsetPos, 1.0);
v_position = mvPos.xyz;
v_eyeVector = (u_resolution * 0.5) - v_position;

gl_Position = u_perspective * mvPos;
}

0 comments on commit 88313b9

Please sign in to comment.