This content is from Minecraft VR. They call it the immersive mode and the classic mode. Users have the option to switch between playing the game with full immersion of VR and playing it on a virtual TV sitting in a virtual room. I want to create a similar feature in my current project. I’m well experienced with unity , so I’m not looking for an in-depth tutorial on how to do this. I just need ideas as to what is the best way to achieve this kind of an effect. Any thoughts, references and input is welcome
I’ve not experienced the minecraft transition in the GIFs.
I assume classic mode is the game viewed on a 2D virtual screen, that is: it isn’t a framed portal on the wall looking into a 3D scene, it is a VR monitor. Then the transition turns the 2D monitor into a 3D portal and the frame is expanded out.
Here’s how I would do it:
- Take regular game scene.
- Put two cameras in it.
- In that scene add a modest little VR cinema mesh using 1 material/atlas, no Ztest highest render queue - 1.
- The screen on the cinema wall is textured with a read/write enabled textureG, no ZTest highest render queue.
- Cam1 is the game camera, riding around like a normal game cam.
- This renders to textureG in the VR cinemas monitor.
- Cam2 is sat in (child of) the cinema viewing the screen.
- Position cinema way outside game scene, like X,Y,Z = -10000.
- Rotate cinema so that the real game scene is outside of Cam2 fustrum (opposite side of cinema to screen).
- To transition you need to:
- Pause game.
- Teleport cinema so its child Cam2 is at Cam1 pos/rot.
- The Ztest off and render queue setup prevents game geometry clipping into cinema, at the expense of overdraw.
- Fade screen material to transparent.
- Cam2 is now looking at a portal into the real scene.
- Kill Cam1.
- Translate the screen frame and quad toward Cam2.
- When dist <= minCam2 viewdist kill cinema and screen and you’re left in a regular game.
The above scheme may need some fixing/refinement/optimizing, but it’s where I’d start.
The expanding frame, indeed any more complex geometry in the cinema would be an issue with no ZTest, fixed cam2 position makes that solve able by triangle index ordering though. But for a simple cinema cube where the screen is a rectangle on one wall the above would work out of the box.
Another option is to ensure that the transition can only ever occur when Cam1 is out in the open, perhaps near a predifined marker in the game, at this spot no geometry intersection will occur and no ZTest tricks would be needed. No overdraw and far more forgiving for mobile.