You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, all visible layers are independently painted to the canvas, which is hugely inefficient. Instead, we should loop once over all voxels, compute the final color image in memory, then blit to the canvas just once. This should take us from linear time in the number of layers to close to constant time, since profiling suggests that nearly all of the time is currently taken up by the painting operation.
The text was updated successfully, but these errors were encountered:
I think it might be saner, actually, to keep each layer in an offscreen canvas and then composite them at the end. Blitting canvases over each other is very fast.
One other optimization that might help would be to draw all the layers as individual pixels and then use the canvas transformation to scale the image when rendering. This would also let us get rid of the pixel overlap.
I looked into doing this a while ago; I need to see where I put my code experiments...
I actually have the alpha compositing 95% done now, and it's much faster (scrolls seamlessly through the brain with ~10 layers), so I'll probably stick with this approach. I also switched to ndarrays, and while performance is not noticeably better, the code is much cleaner--we can do nice matrix operations with ndarray-ops. I suspect using multiple canvases would be slower, because we'd still have the extra overhead of painting to off-screen canvases, even if that's much faster than to the on-screen canvas.
The scaling optimization is an interesting idea! Let's see where we are in a couple of days once I merge these changes.
At the moment, all visible layers are independently painted to the canvas, which is hugely inefficient. Instead, we should loop once over all voxels, compute the final color image in memory, then blit to the canvas just once. This should take us from linear time in the number of layers to close to constant time, since profiling suggests that nearly all of the time is currently taken up by the painting operation.
The text was updated successfully, but these errors were encountered: