MCPcopy Index your code
hub / github.com/PavelDoGreat/WebGL-Fluid-Simulation / normalizeTexture

Function normalizeTexture

script.js:309–323  ·  view source on GitHub ↗
(texture, width, height)

Source from the content-addressed store, hash-verified

307}
308
309function normalizeTexture (texture, width, height) {
310 let result = new Uint8Array(texture.length);
311 let id = 0;
312 for (let i = height - 1; i >= 0; i--) {
313 for (let j = 0; j < width; j++) {
314 let nid = i * width * 4 + j * 4;
315 result[nid + 0] = clamp01(texture[id + 0]) * 255;
316 result[nid + 1] = clamp01(texture[id + 1]) * 255;
317 result[nid + 2] = clamp01(texture[id + 2]) * 255;
318 result[nid + 3] = clamp01(texture[id + 3]) * 255;
319 id += 4;
320 }
321 }
322 return result;
323}
324
325function clamp01 (input) {
326 return Math.min(Math.max(input, 0), 1);

Callers 1

captureScreenshotFunction · 0.85

Calls 1

clamp01Function · 0.85

Tested by

no test coverage detected