While working on image processing in the fragment shader (specifically thresholding), I find myself wanting to access the processed result from JavaScript so that I can save the modified image using standard JavaScript methods.
I send the original texture to be segmented to the fragment shader as a uniform, where the thresholding happens. The result renders correctly on screen. But now my goal is to extract this thresholded image for saving purposes.
Considering the fact that the fragment shader runs over pixels rendered on the screen, I'm not even sure if it makes sense to try and access the processed image.
Despite the constraints, I am curious if there is an effective technique to execute complex image processing tasks within the fragment shaders and then somehow retrieve the resulting data for further use.
Another scenario I have in mind involves flood filling based on the mouse cursor position, among other things.
JavaScript's speed is insufficient for my needs, and while web workers may offer some improvement, I was hoping to capitalize on GPU acceleration for my image processing requirements.
(Just for context: I am currently using THREEJS along with custom shaders - though this might not be relevant information)
Warm regards, Nicolas