I have zero graphics programming knowledge, but there’s alot of info about this online. This technique is called “portalling”, which unfortunately due to the game Portal is now very difficult to search for on google.
Portal is probably the most obvious example of this technique. In layman’s terms, it’s essentially a flat texture connected to a camera, which moves and rotates based on the position you view the texture from.
All the documentation for Narbacular Drop (The game the Portal team made as Digipen students) is available online, this is the quote from their technical design document.
The creation of our portals takes place with some extremely simple trickery along with a lot of tedious things to make it work well.
Essentially, a portal is just a textured quad. But the contents of the texture are dynamic and the texture coordinates change based on how you’re looking at the quad.
To create the contents of the texture:
- Convert the current camera position and look vector into coordinates relative to the portal.
- Find this position and rotation in relation to the portal’s exit.
- Move the camera to the point and rotation found in step 2.
- Render the scene while culling all objects between the camera and the portal exit.
- The render surface is now the source texture for the portal and the camera should be moved back to where it was before step 1.
To render the quad with the proper texture coordinates:
- Convert each coordinate into screen space.
- Copy the normalized screen space x and y components into the u and v coordinates of each vertex.
- Render the quad.
This also seems like a good technical explantion: https://torinmr.github.io/cs148/
As for the room itself, I’d guess the room you see in the looking glass videos is hidden outside the level somewhere. If you think back to Half Life 2, those Dr Breen videos you see around City 17 were all running in realtime. There’s a room outside each level with a camera and a Dr Breen model that plays the animations. You can see a video here of someone getting into the room: https://www.youtube.com/watch?v=q_nmpl6yIBA&t=2m32s
This technique is actually something you’ve seen alot and probably never really noticed, because it’s how skyboxes work. Instead of building an entire city environment in the background, you build a miniature version of the city and use portalling to render it at a larger scale. In hindsight it makes the whole helicopter sequence in Prey a really good gamedev in-joke. https://www.youtube.com/watch?v=D6HenZtZje8