Gamasutra: The Art & Business of Making Gamesspacer
Games Demystified: Portal
View All     RSS
September 3, 2014
arrowPress Releases
September 3, 2014
PR Newswire
View All





If you enjoy reading this site, you might also want to check out these UBM Tech sites:


 
Games Demystified: Portal

August 26, 2008 Article Start Page 1 of 3 Next
 

[In the second in this series of articles which deconstructs a particularly fun or interesting mechanic in a recent, relevant game, Jeremy Alessi pulls apart Valve's Portal and puts it back together again -- to give us a clearer understanding of the compellingly-executed teleportation mechanics central to that game's astoundingly entertaining gameplay.]

EDITOR'S NOTE: To download the associated demo and code sample for Portal Demystified, please click here.

Welcome back to Games Demystified. This month we'll be examining the chief gameplay mechanic behind last year's amazing Portal! Anyone who's played Portal has heard GLaDOS state, "Speedy thing goes in, speedy thing comes out".

That line sums up the mechanics that distinguished Portal from the rest of the herd this past winter. Sure, the impressive story and rendering also had a part, but it's simply not a game without the mechanics.

Game mechanics are usually abstractions based on real-world physics. In the previous Games Demystified column, we covered gravity as it was applied in Super Mario Galaxy, a force that is mostly unexplainable and yet tremendously fun with the proper application in gameplay.

This go-round we're looking at wormholes, Einstein-Rosen Bridges, or portals, if you will. These phenomena are predicted by Einstein's theory of General Relativity.


Image From Samuel Joseph George's description of The Einstein-Rosen Bridge

Like gravity, Einstein-Rosen Bridges are mostly a mystery. Perhaps someday through imagination and cool video games we'll gain a proper understanding. Until then, we've got a nice pseudo-laboratory in Portal to experiment with these mechanics.

Just playing the game is a mind-trip. Exactly how can we simulate a tunnel or wormhole through the fabric of space-time? How do we do speedy-in, speedy-out, momentum redirection -- or "flinging", as Valve calls it?

Teleport mechanics in video games are nothing new. Puzzles from the original Gauntlet were memorable -- and more than likely, that wasn't the first game to use teleportation as a gameplay mechanic. The difference between Portal and all those that came before it is that Portal's teleportation acts as a frictionless tube between point A and point B.

Physics are still hard at work inside the frictionless tube. Instead of simply repositioning an object from point A to point B, the player enters point A with full velocity and exits point B with the same speed, but moving in a new direction.


Article Start Page 1 of 3 Next

Related Jobs

Cloud Imperium Games
Cloud Imperium Games — Santa Monica, California, United States
[09.02.14]

Gameplay Programmer
Sony Computer Entertainment America LLC
Sony Computer Entertainment America LLC — Bend, Oregon, United States
[09.02.14]

Senior Graphics Programmer
Uken Games
Uken Games — Toronto, Ontario, Canada
[09.02.14]

Software Developer (Unity)
Sony Computer Entertainment America LLC
Sony Computer Entertainment America LLC — San Mateo, California, United States
[09.02.14]

Senior Software Engineer






Comments


Haig James Toutikian
profile image
Coming from a science background, I can really appreciate articles like this. Very refreshing!

Eric Diepeveen
profile image
Awesome article. You keep picking the most innovative & jawdropping gameplay features from games and turn them into understandable lines of code. Your fascination with physics makes for some awesome reads. Keep up the good work.

Milosz Derezynski
profile image
Haig: Not coming from a science background (well, CS..) i appreciate this article too ;)

Bart Stewart
profile image
Love it. It's like going back to the heady days when Byte magazine still printed code listings.



Knowing how stuff really works is glorious.



Thanks for choosing to publish this, Gamasutra editors!

Dario Hardmeier
profile image
Another great article with very inspiring insights.



I suggest one slight modification to the transformation of the player velocity : instead of changing the velocity direction to the normal of the exit portal, thus changing any movement at a right angle to the portal normal into forward motion, i propose projecting the velocity vector onto the basis vectors of the entrance portal. This gives back the players velocity relative to the entrance portal's orientation. This new velocity can then be multiplied with the basis vectors of the exit portal, resulting in the "correct" transition.



Might be a few more lines of code (and a bit more of a hassle with setting up the basis vectors), but allows far more possibilities when playing around with portals.



Things could even be taken further when using different sizes of portals (ie differing, non-normalized basis vectors for the entrance and exit portals), in combination with scaling of objects passing through a portal. For a very nice example of this, see Peter Molyneux's GDC 2005 "Room" demo ( http://www.youtube.com/watch?v=vGiPUx9Zgi0 ).



PS: Very looking forward to you next article!

Anonymous
profile image
I would've liked to hear about the rendering of the portals as well, which it seems to me is the more technically challenging part. There was a commentary node about it in the game: as I recall, they iterated through several methods, each of which had its own performance issues, and eventually arrived at rendering inside a stencil buffer using a different camera. I would expect this to put particular pressure on the vertex unit of the GPU, which may explain why they chose very clean-looking environments that are low on vertices. It's also only done to two levels of recursion, after which further portals are cheaply faked by only rendering the fiery oval instead of the actual scene. Very clever to use a stencil buffer for such an unusual trick.

Anonymous
profile image
You're absolutely right. The rendering part is so much more interesting. I think everybody with a bit of understanding on vectors knows how to do this. Probably anybody who can code in Blitz3D. :)



The Room from GDC 2005 is really interesting. I did not get whether they included this mechanic in BW2???

Shay Pierce
profile image
I'm with everyone else on wanting to see some practical implementations of the portal rendering. But since the author was apparently writing this on the eve of his wedding, I certainly forgive him for only analyzing ONE fascinating piece of code. :)



Maybe the next installment of the column could come back to Portal and analyze that part as well.



If not, I'd like to see the next one be about Braid's time rewinding mechanics! Seems like Jon Blow has described how he did it enough times that it would be easy to reverse-engineer. But even when you know you could do it yourself if you had to, there's something about seeing someone else actually implement it and share the code - even if it's a non-refined implementation - that gets the creative juices flowing. Thanks for the articles Jeremy!

Anonymous
profile image
The rendering of the portals is not quite right. The portals are obviously rendered with a set camera position, but should be rendered using the direction of the player to give a correct perspective on the 2D plane. For instance if you walk up to one of the portal entrances and look diagonally in it, it does not look correct.


none
 
Comment: