Skip to content

Commit

Permalink
Increase damping coefficient and use gradual reduction for masking, see
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Jan 8, 2019
1 parent 178aba4 commit 5c47f1e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions js/common/model/Lattice.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ define( require => {
const WAVE_SPEED = 0.5;
const WAVE_SPEED_SQUARED = WAVE_SPEED * WAVE_SPEED; // precompute to avoid work in the inner loop
const NUMBER_OF_MATRICES = 3; // The discretized wave equation algorithm requires current value + 2 history points
const DAMPING_COEFFICIENT = 0.999; // wave values scaled by this much at each frame to wash out numerical artifacts
const DAMPING_COEFFICIENT = 0.9999; // wave values scaled by this much at each frame to wash out numerical artifacts

// This is the threshold for the wave value that determines if the light has visited. If the value is higher,
// it will track the wavefront of the light more accurately (and hence could be used for more accurate computation of
Expand Down Expand Up @@ -193,9 +193,9 @@ define( require => {
* @param {number} j
* @public
*/
clearCell( i, j ) {
reduceCell( i, j ) {
for ( let k = 0; k < NUMBER_OF_MATRICES; k++ ) {
this.matrices[ k ].set( i, j, 0.0 );
this.matrices[ k ].set( i, j, this.matrices[ k ].get( i, j ) * 0.95 );
}
this.visitedMatrix.set( i, j, 0 );
}
Expand Down
2 changes: 1 addition & 1 deletion js/common/model/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ define( require => {
const cameFrom2 = this.temporalMask2.matches( i, j, this.stepIndex );

if ( !cameFrom1 && !cameFrom2 ) {
this.lattice.clearCell( i, j );
this.lattice.reduceCell( i, j );
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions js/common/model/TemporalMask.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ define( require => {
const theoreticalTime = time - distance / Lattice.WAVE_SPEED;

// if theoreticalDistance matches any time in this range, then we have a winner
const tolerance = 4;
if ( theoreticalTime >= startTime - tolerance && theoreticalTime <= endTime + tolerance ) {
const headTolerance = 4;
const tailTolerance = 4;
if ( theoreticalTime >= startTime - headTolerance && theoreticalTime <= endTime + tailTolerance ) {

// Return as early as possible to improve performance
return true;
Expand Down

0 comments on commit 5c47f1e

Please sign in to comment.