- Home /
Seamless portals into other spaces
Not trying to make a replica of Valve's Portal, just very curious about the technique behind the solution of seamless teleportation between one space to another. This could surely be done in Unity (graphically with cameras and rendertextures and technically with trigger areas to ghost through a bit of the wall), but what happens codewise when the player goes through a hole in one location to wind up on the other side of the hole without glitches in between (so all view angles of entry/exit seem seamless)?
Would it be a good idea to duplicate the room so there are two rooms at all times or is this just a position arrangement of the player? Once entering the entry portal you immediately transform the position to the exit portal with the same view rotation as when the entry were made. One thing to bear in mind is the cameras near clipping as you get really close to the wall on entry.
As this could be used for other technical reasons in a game the solutions are very interesting to discuss. How would you solve a seamless portal?
everyone is saying the rendering part is easy but i can't figure it out. i understand the Stencil Buffer Technique but in Unity and RTT i just can't get the angles right.
this is my progress: http://uploadpic.org/storage/2011/wJcbVRDAzZLfYwVmVxnyH9fLF.jpg
This gets really twisty in my head when thinking of it, but bear with me. I think the rendertexture's camera has to be moved the same way as the first person camera but position referenced as to the output position of the "exit"-portal. So while looking into the "entry"-portal it would behave as you were looking straight into the other room with the same distance and rotation.
yes i thought so too. but you get smaller picture every time.
Yeah you're right, didn't think of that! The z-location should be fixed to the exit-position to solve that.
for the sake of simplicity i am trying to create a 2 portals in same position. so i get seamless transition to scene behind portal. the relativity of 2 portals later is easy.
Answer by ggappleid · Apr 27, 2012 at 10:58 AM
I am an author of "Portalizer" package that you can find in AssetStore. Here is explanation of how i made a seamless portals for teleporting objects and FPS (pakcage include only object teleporting).
1) Rendering: i look into MirrorReflection shader and script that you can find in Wiki. I have add two mirrors on scene and my goal was to render Reflection for camera that look on other mirror. I have modified transformation matrix that know relations between 2 portals and voila, all works fine.
2) Object teleporting: i have add inner trigger zone to portal which activates when you add moving object here. It simply create clone of this object and add script to it, that control his position and rotation using similar transformation matrix (like in previous step)
3) I have add a few zones to portals that send info about colliders to global script that manage them (enable|disable collision with walls, other objects e.t.c.)
4) To make object culling visually when it is inside portal, i have used interesting shader that i found on forum written by Aras. I modified it and got cool result, now my portals are connected and can seamless teleport object.
5) FPS teleporting: This is the most tricky part. How to teleport camera? I thinking about it too much and here is what i get. To make Camera looks fluid, i played with "Depth only" option. When i am creating clone for FPS, i also create Eyes for it, with absolutely the same params as your MainCam with rotation and position multiply on transformation matrix. Then i "wear glasses" while going through portal. This is basically a plane with transparent shader placed in front of camera. Then i placing projector behind each portal that project "Depth only shader" on this glasses and mix 2 camera views automatically.
You can try my final project here. Good luck
Aloha, I noticed that the Portalizer package is now deprecated. Are you planning to make an updated version or new package?
Answer by Anxo · May 29, 2011 at 08:00 PM
I used portals (black holes) for my "AstroNut 3D" game.(plug!) The player is able to jump from one location to another of the same level (room).
My character had a rigidbody attached to it and moved by Rigidbody.AddForce so what I did was when the player hit on black hole, The direction and speed of the character is stored in varibles, then an animation plays of the character flying in the black hole and the camera flew over to the other black hole, the position of the character was moved to the second blackhole and an animation was played for the character coming out. Then the stored velocity's direction and speed is reapplied to the character so that the player knows where he/she is flying once they came out of the black hole allowing them to plan on which direction to enter it from.
People are not able to look in the portal but if you need a portal you can look into and see the same thing thats happening you could use a camera in that location and then render to texture on a plane thats in that same location. But you would need Unity Pro Depending on your situation it might just be as simple as
on collision enter, player position = new position.
Interesting solutions, there might be a good point to let animations take over the logic in the enter-exit moment to solve a few issues with the seamlessness. Awesome reading thanks Anxo.
Answer by DanJC · Apr 25, 2013 at 08:35 AM
http://answers.unity3d.com/questions/421450/how-can-i-render-a-scene-to-a-surface.html#answer-444650
Two-line shader handles the viewing aspect, and it works in Unity Standard. Not sure about the stepping through.
Answer by BornOnFire · Jul 04, 2015 at 07:09 PM
I Just finished making the portals from this video https://www.youtube.com/watch?v=sK9Qf8ElFHo Easy to understand and now with Unity 5 its available to do it with the free version. Made the portals into a Prefab for my project.
Your answer
![](https://koobas.hobune.stream/wayback/20220612091650im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can I make a character disappear from view from one side to the other? 1 Answer
Portal between scenes? 3 Answers
Advice on portal clone (More cameras in 1 scene) 1 Answer
Teleportation problem! 1 Answer
Depth mask Portal Method. 0 Answers