When trying to hittest with a large amount of data (but with almost none of it on screen) read pixels is really slow even though frame times are way below 16.7ms (10ms all in)
I'm working on a datavis platform running in webgl but something thats baffling me is why readpixels is so slow. We are using the colour picking approach to hittest an item that being dragged so that it can br dropped on to things etc. It seems the more data uploaded into the scene the longer it takes despite the render (without read) is 60fps. Its only pulling one pixel out so its clearly related to the blocking aspect of it but why would that take nearly 4x longer than the frame time?
if (xPos >= 0 && yPos >= 0 && xPos < drawBufferWidth && yPos < drawBufferHeight) {
gl.readPixels(xPos, yPos, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, lastCapturedColourMap);
}
I would expect that the higher the framerate the lower the cost of readpixels but it seems to be a fixed cost. Could anyone enlighten me? I'm looking for anyone who might understand better about what actually makes it slow or for any other alternative hit testing method for 2d graphics in webgl