Grabbing the screen and then doing more rendering?

I know that Unity changed how mobile screen grabbing works in Unity 3.5 (i think) so that if you want to grab the screen it has to basically be done after a camera is done rendering or at the end of the frame. But here’s what I want to do:

  1. Draw something to the screen
  2. Grab that or a portion of it into a texture
  3. Fill the screen with different content based on that texture which was grabbed
  4. Flip the buffer into view

All this needs to occur in one frame not spanned across frames. I’m using Unity Free version otherwise I’d use rendertextures.

One strategy I can think of is:

  1. Disable all cameras
  2. Use a first camera which renders stuff to the backbuffer, trigger it manually to render (is that possible in Unity Free?)
  3. In that camera’s OnPostRender() (or other way to detect it’s done?) grab a copy of the backbuffer into a texture (I don’t need to offload it to the cpu or change it with setpixels or anything - step 2 already modified it with the gpu)
  4. Use a second camera which now renders a screen full of pixels based off the texture which was just grabbed, trigger that camera manually to render as a second pass.

Will this work within a single frame? Especially, will this work on mobile which has this caveat about grabbing after the camera is drawn? It almost sounds like you can’t use what you grabbed until the next frame but I hope that just means you have to let A camera finish first before you can grab from it? And then you can render more stuff after?

Just for reference the way to make this work is to disable a camera with camera.enabled=false, then call Camera.Render() on it manually. In the camera’s OnPostRender() function you can then do readpixels and apply(), AND then you can go ahead and do more passes with the same camera or other cameras, all within a single frame.

RenderTextures were “invented” JUST for that kind of stuff :wink:
seriously though, you are going in the wrong direction. First: it will be slow. Like really slow. Second: you misunderstood what’s this all about: basically we enforce the rule that your display buffer may only be accessed while you are rendering to it; after you’ve done - no more access (if you read up on double buffering and tiled architectures - you should be able to connect the dots).OnPostRender is still called while you are rendering, so you should be able to ReadPixels here. But again - i strongly advise RenderTextures as what you describe is painfully slow way of emulating it

Thanks for the info and I recognize this is slow but I do not own Unity Pro. Also this is not for realtime use but for level generation.