Portal

wow, and here i was musing to myself how i would try to set up prey style warps wall walking when i one day become a big strong programmer (i’m drinkin milk!) - then i see this. amazing.

(keep watching it gets better)

I was thinking about this today too, actually! The best I could come up with would be to create a plane at each portal point, with a Render Texture coming from a camera attached to the opposite portal. This would require Unity Pro of course.

From there, I figured the teleportation mechanics could work by changing the player’s transform point to the other portal when they collide with one portal. This all sounds doable in theory, but who knows how well it would work in practice. Anyone want to give it a shot??

basically my thinking too. in the linked vid i can’t tell if the ‘snap’ you see when moving through is intentional or an artifact of switching from the render-texture view to the camera view.

also, it seems you would have to possibly dupe the object moving through as you can see it halfway in one portal out the other in some shots.

i found the design document from the guys who did narbacular drop (and now work at valve doing portal). some interesting stuff in there. PDF!

so far i’ve read they did a render to texture for the visual used the object center to decide what side of the the portal to calculate physics with.

What happens when then perspective when looking through a portal means you’re looking from inside a wall?

As far as I could see from watching it once, they avoided that in the video. :slight_smile:

I bet we could get a game like this running in Unity in no time.

-Jon

They also seem to have avoided showing what happens when you fire a portal into a corner or on some curved object…

Gotta love neglecting corner cases in promotional videos. :slight_smile:

-Jon

Have you seen the trailer to TF2? I’m not sure if this will ever be released as this has been around for so many years… ;O)

Anyway the graphic style in the trailer is just marvellous!!!

Only do have a low res public link… http://www.youtube.com/watch?v=NaF638MBSAE

Couldn’t resist. It’s a really cool idea and so simple to implement in Unity. (requires pro of course)

Here it is:
www.otee.dk/joe/portal/index.html
Run with arrow keys, spawn portal with ctrl.

Be aware it’s all abstract environments (That is a couple of cubes).
Hope someone can put this into a nice environment. Also there are still some things to be worked out. Like:

  • making a funky shader that fades in the portal effect with the alpha mask they are using. At the moment it’s just a simple plane showing the view from the other portal
  • making it work correctly on corners etc. Simplest way to do it would probably be to use the projector with orthographic projection instead.

Project folder:
www.otee.dk/joe/portal/portal.zip

wow really cool.
i never thought about it (noob), but its amazing how useful render-to-texture can be for all sorts of creative things, yet another reason to buy pro when get the money.

thank you for providing the files ; )

lol - i’ve never played team fortress, does that humor translate to the gameplay?

not sure what you are asking.

at first i figured they just set it up so you can’t fire into a corner, though joe has a good idea for it - so maybe they just arent showing it. (it is an early prototype)

@drJones
I’ve no idea either. I only know that TF2 has been announced since some years, got cancelled, Valve got pissed when beeing asked about it and so on. It looked completely different in the beginning. This is the first time i saw that they took a comic style route now so i guess that this also will affect gameplay a bit due to the different atmosphere…

Portal reminds me a bit of Dungeon Master/Chips Challenge…i like the black white portal device…

@Joachim
You see how “IN” boxes are, don’t you! ;O)

Really neat… the main thing missing to me is that the perspective of the portal image doesn’t change as you walk around it. I think this would require setting up a weird camera matrix for the render texture cameras to get it right. Do you know how you’d do it?

I can draw a diagram if I wasn’t clear.

-Jon

Cool.

Another tweak to make: right now, if you go through portals at right angles to each other you come out sideways.

I thought about this too… I think it is simply a matter of calculating the player’s position relative to each camera, and rotating the render texture camera to fit with the player’s line of sight.

I’m at work right now and don’t really have the capability to play with this, but this could be an awesome collaboration project, especially with the buzz in Targos’s thread.

Jeff: Is it possible to set up team project collaboration pages on the wiki?

This could be a heck of a lot of fun…

If this turns into a team project I am totally in.

It wouldn’t be just rotating the camera to line of sight, it would also need the correct relative position/distance. So that when you walk towards the portal, even though your sight angle doesn’t change, you still see the change in the view from your forward motion.

That’s what I meant when I said earlier: What happens when the player’s view makes the render texture camera look from through a wall? The video never showed this corner case. (Pun very much intended!)

-Jon

Hmm… that’s an interesting scenario. If it were me, I would just force the portal a minimum distance away from a corner, so that when you’re looking through to the camera, the render texture camera simply can’t look through the wall, just at it.

You can adjust the projective and world matrix of a camera as you like. We use that for the water.

It might actually be somewhat similar case, because there we create a reflected projection matrix and then adjust the matrix to be clipped along the water plane. You might want to take a look at the water script for how that is done.

http://unity3d.com/Documentation/ScriptReference/Camera.projectionMatrix.html

http://unity3d.com/Documentation/ScriptReference/Camera.worldToCameraMatrix.html

I am working on a portal system that doesn’t use render to texture, just some fancy shader and layer stuff. Here is my progress so far: