Take a screenshot in realtime then use it immediatly as Texture

Hi everyone,

I’m student in a Game Design school and I am currently working on a transition effect.

Let me explain what I want to do.

I have a 3d view of my scene with 3d models.

Step 1 : Apply a blur on the camera.

1521017842-img-01.png - envoi d'image avec NoelShack

1521018086-img-02.png - envoi d'image avec NoelShack

No problem with this.

Step 2 : Keep the view the 3D scene behind as background then reveal my canvas.

1521018230-img-03.png - envoi d'image avec NoelShack

1521018233-img-04.png - envoi d'image avec NoelShack

I got inspired by a graphic effect in Frostpunk.
Here the example at 00.27.

So the idea I have to realise that is to :

  1. Apply blur on camera.

  2. When done I take a screenshot of my screen and store it.

  3. Apply this screenshot as texture on a plane in front of camera

  4. Display my canvas behind this plane

  5. Apply a disolve on the plane with screenshot texture to reveal the canvas behind

The main problem comes from the function ScreenCapture.CaptureScreenshot().
The function works but the screenshot seems to be stored AFTER I stop the game and not during.

I dont know how to use it properly in runtime.

I hope everything is understandable. If you have any question I am available to anwser.

Thank you in advance.

@Juliken You can use a render texture for this. Create a render texture at the desired resolution and get a reference of it in your script.
After the blur is applied, assign the render texture to your camera (camera.targetTexture = yourRenderTexture). This will save everything the camera sees in your render texture. Before the frame ends don’t forget to make the target texture of the camera null, otherwise the camera will render in your render texture and nothing will be displayed on the screen.
Now you can assign your render texture as the main texture on a material (if you want to use the plane implementation, or as the texture in a rawImage).