It's free to join Gamasutra!|Have a question? Want to know who runs this site? Here you go.|Targeting the game development market with your product or service? Get info on advertising here.||For altering your contact information or changing email subscription preferences.
Registered members can log in here.Back to the home page.

Search articles, jobs, buyers guide, and more.

Gamasutra
August 26 2008

Games Demystified: Portal

arrowrightPage 1
arrowrightPage 2
arrowrightPage 3


Printer Friendly Version



Sign up for the Gamasutra Daily Newsletter!

Namco Networks America Inc. : Flash Games Engineer [11.21.08]
War Drum Studios, LLC : Network Game Programmer [11.21.08]
First Act Interactive : Project Lead Software Engineer [11.21.08]
Sony Computer Entertainment America : Senior Manager of Game System Engineering [11.21.08]
Cryptic Studios, Inc. : Lead Game Master Support Representative [11.21.08]
Sparkplay Media : QA Manager [11.21.08]
Cryptic Studios, Inc. : User Interface Designer [11.21.08]
Treyarch / Activision : Technical Director [11.21.08]
Ignition Entertainment : Motion Director [11.21.08]
Ignition Entertainment : Producer [11.21.08]
Sony Pictures Entertainment : Software Engineer / Lua Scripter [11.20.08]
Sony Computer Entertainment America : SR. TECHNICAL PROJECT MANAGER [11.20.08]
Edge of Reality : Project Manager [11.20.08]
Stealth Startup : 3d Graphics Programmer - Virtual Worlds [11.20.08]
Carbine : User Interface/2D Artist [11.20.08]

View All    Post A Job

Post Resume


Upcoming Events:
DIG London Game Conference
London, Canada
11.27.08

5th Australasian Conference on Interactive Entertainment
Brisbane, Australia
12.03.08

IEEE Symposium on Computational Intelligence and Games
Perth, Australia
12.15.08

2K Bot Prize
Perth, Australia
12.15.08

The 6th Annual Mobile Games Forum 2009
London, United Kingdom
01.21.09

Submit Event

View All


Games Demystified: Portal

(Page 1/3)
Next arrow


[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.


(Page 1/3)
Next arrow


Comments


Haig James Toutikian 26 Aug 2008 at 6:36 am PST
Coming from a science background, I can really appreciate articles like this. Very refreshing!


Eric Diepeveen 26 Aug 2008 at 10:50 am PST
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 26 Aug 2008 at 1:32 pm PST
Haig: Not coming from a science background (well, CS..) i appreciate this article too ;)

Bart Stewart 26 Aug 2008 at 2:21 pm PST
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 26 Aug 2008 at 3:41 pm PST
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 26 Aug 2008 at 6:25 pm PST
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 26 Aug 2008 at 8:31 pm PST
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 27 Aug 2008 at 1:22 am PST
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 27 Aug 2008 at 11:42 pm PST
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 28 Aug 2008 at 4:45 am PST
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.







join | contact us | advertise | write | my profile
news | features | contract work | jobs | resumes | education | product guide | store