Skip to content

Commit

Permalink
Merge pull request CesiumGS#11553 from CesiumGS/fix-normal-scaling
Browse files Browse the repository at this point in the history
Fix scaling of czm_normal
  • Loading branch information
lilleyse authored Oct 5, 2023
2 parents 45300f3 + 9556061 commit 4ce2d16
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

### 1.111 - 2023-11-01

#### @cesium/engine

##### Fixes :wrench:

- Fixed `czm_normal`, `czm_normal3D`, `czm_inverseNormal`, and `czm_inverseNormal3D` for cases where the model matrix has non-uniform scale. [#11553](https://github.com/CesiumGS/cesium/pull/11553)

### 1.110 - 2023-10-02

#### @cesium/engine
Expand Down
26 changes: 8 additions & 18 deletions packages/engine/Source/Renderer/UniformState.js
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,6 @@ function cleanNormal(uniformState) {

const m = uniformState._normal;
Matrix4.getMatrix3(uniformState.inverseModelView, m);
Matrix3.getRotation(m, m);
Matrix3.transpose(m, m);
}
}
Expand All @@ -1524,36 +1523,27 @@ function cleanNormal3D(uniformState) {

const m = uniformState._normal3D;
Matrix4.getMatrix3(uniformState.inverseModelView3D, m);
Matrix3.getRotation(m, m);
Matrix3.transpose(m, m);
}
}

function cleanInverseNormal(uniformState) {
if (uniformState._inverseNormalDirty) {
uniformState._inverseNormalDirty = false;
Matrix4.getMatrix3(
uniformState.inverseModelView,
uniformState._inverseNormal
);
Matrix3.getRotation(
uniformState._inverseNormal,
uniformState._inverseNormal
);

const m = uniformState._inverseNormal;
Matrix4.getMatrix3(uniformState.modelView, m);
Matrix3.transpose(m, m);
}
}

function cleanInverseNormal3D(uniformState) {
if (uniformState._inverseNormal3DDirty) {
uniformState._inverseNormal3DDirty = false;
Matrix4.getMatrix3(
uniformState.inverseModelView3D,
uniformState._inverseNormal3D
);
Matrix3.getRotation(
uniformState._inverseNormal3D,
uniformState._inverseNormal3D
);

const m = uniformState._inverseNormal3D;
Matrix4.getMatrix3(uniformState.modelView3D, m);
Matrix3.transpose(m, m);
}
}

Expand Down

0 comments on commit 4ce2d16

Please sign in to comment.