Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
oculus_dzne's avatar
oculus_dzne
Explorer
10 years ago

Grab a screenshot from Rift and immediately display it

Hello everyone, 

for an experiment we would like to grab a a screenshot from the rift (i.e what the Unity camera renders to it) and display it immediately for about a second. We tried the following code:

Camera camOV = mainCam; //OVRPlugin OVRController
camOV.targetTexture = tex; // A public RenderTexture

RenderTexture currentRT = RenderTexture.active;
RenderTexture.active = camOV.targetTexture;
camOV.Render();

Texture2D imageOverview = new Texture2D (camOV.targetTexture.width, camOV.targetTexture.height, TextureFormat.RGB24, false);
imageOverview.ReadPixels (new Rect (0, 0, camOV.targetTexture.width, camOV.targetTexture.height), 0, 0);
imageOverview.Apply ();

yield return new WaitForSeconds (2);

//RenderTexture.active = currentRT;
camOV.targetTexture = RenderTexture.active;


However, this results in a certain flicker for 2 seconds (although it looks fine in the editor). How else can we achieve this? 
Thanks in advance


/Seb
No RepliesBe the first to reply