Skip to content

Commit

Permalink
Consider inverse y-axis
Browse files Browse the repository at this point in the history
  • Loading branch information
StuckiSimon committed Aug 19, 2024
1 parent 4a03139 commit dc745b1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions strahl-lib/src/path-tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,17 @@ async function denoise(

var imgData = new ImageData(size.width, size.height);
const clampedData = new Uint8ClampedArray(data);
for (var i = 0; i < clampedData.length; i += 4) {
imgData.data[i] = clampedData[i];
imgData.data[i + 1] = clampedData[i + 1];
imgData.data[i + 2] = clampedData[i + 2];
imgData.data[i + 3] = clampedData[i + 3];
for (let y = 0; y < size.height; y++) {
for (let x = 0; x < size.width; x++) {
// Consider flipping the image
const sourceIndex = ((size.height - 1 - y) * size.width + x) * 4;
const targetIndex = (y * size.width + x) * 4;

imgData.data[targetIndex] = clampedData[sourceIndex];
imgData.data[targetIndex + 1] = clampedData[sourceIndex + 1];
imgData.data[targetIndex + 2] = clampedData[sourceIndex + 2];
imgData.data[targetIndex + 3] = clampedData[sourceIndex + 3];
}
}

return new Promise((resolve, reject) => {
Expand Down

0 comments on commit dc745b1

Please sign in to comment.