- Home /
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.
No problem with this.
Step 2 : Keep the view the 3D scene behind as background then reveal my canvas.
I got inspired by a graphic effect in Frostpunk. Here the example at 00.27.
https://www.youtube.com/watch?v=UxTxUL_8VkA&t=27s
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.
Answer by Neamtzu · Mar 14, 2018 at 10:26 AM
@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).
Tank you for your quisk answer !! I feel bad to not think about RenderTexture I will try this way
I finally didn't use a render Texture but I found a solution.
I used the ReadPixel function to get an image of my scene with the blur effect then I reveal a plane in front of my camera with the "screenshot" on texture. Then I apply my dissolve on this plane.
Be carrefull, to have a good result you need to use the ReadPixel function in the OnPostRender function.
Your answer
Follow this Question
Related Questions
Need some help with dynamic object fracture 0 Answers
Take photo in unity 1 Answer
Capture camera output 1 Answer
Unity 5: How to enter prefab mode? 1 Answer
Capture screen of other spot 1 Answer