Thanks guys for help. I have made some progress.
Here is the result: http://www.babylonjs-playground.com/#1OJL6I#68
It is something which we could call a "visibility probe", something like a poor man's occlusion query system but for a bit different purpose.
It renders 6 textures of cube around main camera. Then reads textures using modified version of engine.readPixels and analyzes visibility of all meshes.
Meshes indexes are color coded into textures. Yo can see visible list of indexes at black bar at the top of the screen. Use mouse and arrow keys to fly between meshes.
This way you can do 1 render of texture per frame _at most_.
What i need is do arbitrary number of renderings of the same texture, per frame, before render main screen.
This is because i need to put on the scene arbitrary number of those visibility probes, but it will be waste of texture memory, because each probe needs 6 textures.
So using just one probe used multiple times before main render is preffered.
Your method is a bit slow, you use main screen rendering instead of render texture, and recreate texture every time.
But it gave me an idea. Instead of using DumpFramebuffer and recreating texture i looked into babylon source and found engine.readPixels, and i made custom version of it which does not allocates new TypedArray every time but uses same one. And used it in after render observable of renderTargetTexture
@Deltakosh I will be doing that "visibility probe" again but as a proper class. (what I made in PG is just a messy but working prototype )
Are you interested in putting such component into the library ?
It is not easy to explain things properly, so to make things more clear I prepared some more screenshots.
They were made using PG from my first post in this topic ( http://www.babylonjs-playground.com/#1OJL6I#8 )
The behavior described happens in the playground and without playground as well. Without playground instead of moving slider one can resize the browser window to see that.
first pair for doNotChangeAspectRatio=true , in both slider positions: