sphere icon indicating copy to clipboard operation
sphere copied to clipboard

8bit good for lighting and such - 32bit view for pixel copy?

Open Sarah-C opened this issue 3 years ago • 2 comments

This may speed it up a little?

let ctx = c.getContext("2d"); let canvasDataWrapper = ctx.getImageData(0, 0, c.width, c.height); let canvasData = imageDataWrapper.data; // 8 bit ARGB let canvasData32 = new Uint32Array(canvasData.buffer); // 32 bit pixel

copyFnc = function(idxC, idxT){ canvasData[idxC + 0] = textureData[idxT + 0]; canvasData[idxC + 1] = textureData[idxT + 1]; canvasData[idxC + 2] = textureData[idxT + 2]; canvasData[idxC + 3] = 255; };

Vs

copyFnc = function(idxC, idxT){ canvasData32[idxC] = textureData32[idxT] };

Sarah-C avatar Jun 27 '22 18:06 Sarah-C

Hi thanks for your interest and taking the time to post this. I might not have time to look at this for a couple of months but I've always been curious as to whether this could be speeded up so I'm sure I'll look at it at some point.

SamHasler avatar Jun 28 '22 08:06 SamHasler

I'm a firm believer of "relaxation driven development." That's where you're relaxed and decide to do a little bit of a puzzle/code for fun. Not that much around these days! Catch up with you in a month or two!

Sarah-C avatar Jun 28 '22 11:06 Sarah-C