I have an image and I want to draw an arbitrary number of objects on that image. The center coordinates of those objects are calculated inside a fragment shader after series of image processing operations. However, because fragment shader gets executed per-fragment, I cannot draw objects centered on those points in the same shader in a reasonably fast way. Somehow, I need to pass those center coordinates that I calculated in my fragment shader to another fragment shader in a second render pass, preferably as uniforms. Then I can use those coordinates in the second fragment shader to draw my objects in an efficient way.
I thought maybe I can render those points as white spots on a black texture, and after the first pass, I can search the raw data of the texture on the CPU side, then add those white points' coordinates into an array, and send them as uniforms. However, I guess it would be very inefficient as it is a very sparse data (a lot of black pixels and very few white pixels), and I would be doing thousands of iterations (even for a simple 720p image) on that raw data. So, I'm not sure if this should be the way to go.
How can I do this in an efficient way, in OpenGL ES 2.0?
P.S. I'm new to this area, please enlighten me if I made no sense.