Skip to content

Commit

Permalink
reverting scratch matrices. Async sorting clobbers them across tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
keyboardspecialist committed Jan 17, 2025
1 parent 76ea60a commit f98cbbf
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions packages/engine/Source/Scene/Model/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -2178,19 +2178,17 @@ function updatePointCloudShading(model) {
}
}

const scratchViewMatrix = new Matrix4();
const scratchModelMatrix = new Matrix4();

function updateGaussianSplatting(model, frameState) {
//if the camera has rotated enough, update commands
const viewMatrix = new Matrix4();
Matrix4.multiply(
frameState.camera.frustum.projectionMatrix,
frameState.camera.viewMatrix,
scratchViewMatrix,
viewMatrix,
);

if (defined(model._previousViewProj)) {
model._previousViewProj = scratchViewMatrix;
if (!defined(model._previousViewProj)) {
model._previousViewProj = viewMatrix;
return;
}

Expand All @@ -2204,18 +2202,19 @@ function updateGaussianSplatting(model, frameState) {
}

const dot =
model._previousViewProj[2] * scratchViewMatrix[2] +
model._previousViewProj[6] * scratchViewMatrix[6] +
model._previousViewProj[10] * scratchViewMatrix[10];
model._previousViewProj[2] * viewMatrix[2] +
model._previousViewProj[6] * viewMatrix[6] +
model._previousViewProj[10] * viewMatrix[10];

if (Math.abs(dot - 1) > CesiumMath.EPSILON2) {
if (prim?.isGaussianSplatPrimitive) {
const modelViewMatrix = new Matrix4();
Matrix4.multiply(
frameState.camera.viewMatrix,
model.modelMatrix,
scratchModelMatrix,
modelViewMatrix,
);
model._previousViewProj = scratchViewMatrix;
model._previousViewProj = viewMatrix;

if (!prim?.hasGaussianSplatTexture) {
model.resetDrawCommands();
Expand All @@ -2229,7 +2228,7 @@ function updateGaussianSplatting(model, frameState) {
const promise = GaussianSplatSorter.radixSortIndexes({
primitive: {
positions: new Float32Array(posAttr.typedArray),
modelView: Float32Array.from(scratchModelMatrix),
modelView: Float32Array.from(modelViewMatrix),
count: idxAttr.count,
},
sortType: "Index",
Expand Down

0 comments on commit f98cbbf

Please sign in to comment.