Contents
Games Demystified: Portal
 
 
Printer-Friendly VersionPrinter-Friendly Version
 
Latest News
spacer View All spacer
 
February 9, 2010
 
Ubisoft Q3 Sales Edge Down, As It Ramps Up Big Franchises
 
Analyst: Industry Sales To Rebound In March On Strong Core Slate
 
Flickr Co-Founders Return To MMO Design With Glitch
spacer
Latest Jobs
spacer View All     Post a Job     RSS spacer
 
February 9, 2010
 
Black Lantern Studios
3D Environment and Character Artists
 
Aechelon Technology
Senior Graphics Tools Engineer
 
Black Lantern Studios
Programmer I
 
CCP - China
Technical Artist
 
Black Lantern Studios
Associate Interface Artist
 
2K Games
Web Designer
 
Super Happy Fun Fun
Senior Software Engineer
 
Tarsier Studios
Senior Game Designer
spacer
Latest Features
spacer View All spacer
 
February 9, 2010
 
arrow Television, Meet Games
 
arrow Two Halves, Together: Patrick Gilmore On Double Helix [1]
 
arrow The Road To Hell: The Creative Direction of Dante's Inferno [19]
 
arrow The Sensible Side of Immersion [10]
 
arrow Jumpstarting Your Creativity [5]
 
arrow Truth in Game Design [49]
 
arrow Postmortem: Vicious Cycle's Matt Hazard: Blood Bath and Beyond [4]
 
arrow Developers React: The iPad's Future [16]
spacer
Latest Blogs
spacer View All     Post     RSS spacer
 
February 9, 2010
 
Lineage 2 Interview - 'Freya Update Is Just a Beginning' - Pt.2
 
Swashbuckling for Landlubbers: Why you may already be encouraging piracy! [13]
 
JETRO At GDC 2010: Finding Opportunity in the Japanese Gaming Market
spacer
About
spacer News Director:
Leigh Alexander
Features Director:
Christian Nutt
Editor At Large:
Chris Remo
Advertising:
John 'Malik' Watson
Recruitment/Education:
Gina Gross
 
Feature Submissions
Features
  Games Demystified: Portal
by Jeremy Alessi
10 comments
Share RSS
 
 
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.

Advertisement

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
 
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!

Stone Bytes
profile image
If portals are nothing really new, Portal itself has been a gem for genuinely focusing on a main, say single positive gimmick which is key to the gameplay. Just proof that you don't need games that do all, just be sure that the one core idea or function that supports the whole product is solid and rich enough.
I also honestly hope that people won't start to say that anyone could have made Portal, notably because it's not that hard to "find" the code behind the rule. This is something recurrent you hear from jaleous mouths, but the point is that one guy did it, you others didn't, and too bad for you.

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:
 


Submit Comment