Portal Rendering Part 1 – A Brief History Of Portals

Unseen Diplomacy is all about bending space around the player so they can explore a really big space in a much smaller space. The way we did this in UD1 was technically very simple, but required a lot of careful manual work. For UD2 I want to use portals instead, so let’s do a brief history of portals why they’re super cool and super useful.

Firstly, we’re not dead! Apologies for the radio silence on the blog, Real Life™ has been getting in the way of updating it, but we’re back now and hoping to update a bit more frequently

So, what have we been up to? I’ve been waist-deep in rendering code writing a shiny portal system for UD2 that should make things easier and let us experiment with space a bit more.

Portals, 90s Style

The idea of portals for rendering has been around for a while now. This is the earliest paper I could find that talks about them from 1995. Sean Barrett helpfully pointed out this even earlier paper from 1991 which seems to be the original concept of cells and portals. Sean would use portal rendering for Thief in 1998, which used the cells and portals structure not just for rendering but also to propagate sounds realistically.
The basic idea is:

  • Think of the room you’re currently in. Draw the walls and stuff inside it.
  • The doorway you can see? That’s a portal to the next room. Since you can see it, draw that room too.
  • Windows? Also portals. Draw the ‘room’ (outside) you can see through it.
  • Can you see another doorway through that first doorway? Draw that one too
  • Keep going until you run out of visible portals.



Portals and Mirrors, David P. Luebke and Chris Georges

This is cool because if you’re in a massive FPS level set in a big building with thousands of rooms the game can very quickly figure out which 4 for so rooms you can actually see right now and just draw those.

Then things got weird.

If the game stores a matrix alongside each portal, the ‘room’ you can see doesn’t have to be where you think it is. Flip the matrix and the game can turn a doorway into a mirror by drawing the original room backwards. Add an offset and you can turn a doorway into a teleporter you can see through. Everyone probably knows Portal by Valve which shows some super cool ways but the original Unreal (1998) was BSP and portal based, and one of it’s levels has an ‘impossible’ teleporter:



Unreal, Epic Games

(If you want to see this yourself the run the original Unreal and type: load DmRadikus)

The original Prey game – no not the 2017 version, or the 2006 version but the 1997 version was going to be a pure portal engine will all sorts of trickery shown in their E3 trailer (skip to 0:43).



Prey 97, 3d Realms

Decline

But portals kind of fell out of fashion. It worked great for indoors, but sucked for outdoors. It’s a pain to make objects move through portals cleanly, especially as physics in games became more detailed. And as shadows became standard, it was hard to pair those with portals too.

William Scarboro, who programmed the Prey engine, said later:

“There are many ugly problems in maintaining such an engine […] In hindsight, portal tricks such as these should be used as tricks, not as an engine paradigm.”

Unreal moved to ‘anti-portals’ (now occluders) and the rest of the industry moved too.
First person games started having much more mixed indoors and outdoor environments. Also portals required lots of manual markup to place the portals and sectors between them which was tedious and slow. As computers got faster, dynamic methods of culling like occlusion culling became more practical but requiring less human work.

Reemergence

Portals might have become ‘tricks’ only suitable for weird effects and largely forgotten. But weird tricks are still interesting tricks, and a handful of games made them a core part of gameplay. Portal, Antichamber and Prey (2006) all used them in interesting ways to melt your brain.



Antichamber, Alexander Bruce

Of course, this gets even more weird when combined with VR – the illusion is doubly powerful, but also a lot more complicated to program. Stick around for part 2 when I’ll go into how portals work in Unseen Diplomacy 2, how we’re using them and some of the oddball tricks needed to make them look good.