Recreating UTPortal from UDK in UE4 (the portal effect from Portal in UE4)

I recently posted this on the UE4 Answerhub. Mindfane and I made some progress using a SceneCapture 2d camera that moved and rotated relative to the player, but user Jacky suggested that we post the same question here on the forums to get some more feedback.

[Original Version]](Recreating UDK's UTPortals? - Programming & Scripting - Epic Developer Community Forums)

As you can see in the video posted by Mindfane, the result is still less-than-optimal. Namely, there is noticeable lag for the image through the portal. I have a feeling this is due to the use of ticks for timing the movement of the scenecapture camera.

Any suggestions on how to improve this? Feel free to post any completely different ideas your might have as well.

I created this effect a while back for Unity in C#, and I too have been trying to replicate it for UE4. Unfortunately, no success here. There’s a few things you need for it to work and most of them don’t seem to be available through blueprint. Altering the projection matrix definitely seems impossible in blueprint. A few other issues I quickly ran into were dynamically creating render textures, and dealing with differing camera aspect ratios at run time. As for the visual lag, it’s got to be an issue with when things tick. I would guess that tick is called after each frame is rendered, adding 1 frame of lag at least, and then I’m guessing capture actors are delayed in some way, adding more frames. Really not a clue how to deal with this as I don’t really know when Unreal calls it’s various functions and in what order.

Sorry to say that I don’t have a clue where most of these things are in C++. I’m happy to share my C# code from Unity, but I don’t think it’ll help you much. Still, something I would love to see in Unreal.

Yeah I’m not sure all of this is possible with just blueprint alone. The engine is definitely capable of it, but it doesn’t look like we’ll be able to do it easily (and certainly not with just blueprint.)

Delta seconds seems to be of no use in this situation. Unless there is a different event that can be used in place of Event Tick.

Sounds like something to get added to the roadmap. If you post the request in the roadmap thread there is a good chance they will see it and throw it up there.

I have been researching on this topic for a while.

Played the portal games again and again for several weeks. :slight_smile:

The portal team had released several articles on their tech over the years although never really explain how they implemented the seamless physics across their portals. However I came across some papers which explains how the visual effect can be achieved without using render targets.

The idea is to use Portals (not to be confused with portal game portals). Those are the things used in earlier engines to determine visibility of various sections of the map (I think idTech engine and the first UnrealEngine uses it). I dont know if the current generation engines uses it anymore. Anyway inorder to create a portal-game-portal, we will define one Portal (which is a quad) for each opening. During rendering we do this following things.

  1. render the scene using the active camera. But if the gemetry being rendered is inside the Frustum defined by one of the opening quads (ie the frustum project those 4 vertices along camera look-at direction), we will discard those pixels and do not write anything to the depth buffer.
  2. In this stage, we will adjust the WorldMatrix in relation to the first opening-portal. So effectively by mutiplying each vertex with this modified matrix, we translate the object that are seen through the paired-opening-portal into the opening-portal in consideration. Then we render those geometry like normal. In efefct those will be rendered inside the qaud of the opening-portal.
  3. Repeat step 2 for the other portal.

I got a friend to try this with a simple opengl setup (not done using unreal-engine, since we were not sure how unreal’s rendering worked)

The advantage of this method is:

  • rendering is straight forward. We are actually translating the full geometry to a new location (not permenantly).
  • unreal-engines GPU sprites will still work, and since they test against the dept-buffer for collisions, those particles can go through the portals (but only in camera view).
  • Light can pass from camera area into the portal if using forward rendering. But unfortunately not the other way around. But I think with some clever setup this can be achieved. Have not tried using deffered lighting. But seems to me that lights can pass though portals-in camera view atleast.
  • Screen-space reflections will show things that are inside the portal.
  • No 1 frame lag.


  • If we were using render targets we could do recursive portals without any additional work (ie when two portals look at each other). But in this method, we have to re-render objects to get this effect.
  • Need to edit the rendering code of unreal. The concept of portal should be supported by the engine itself.
  • SceneCaptureComponets may not respect portals.

Would this help?

As far as I can see it does not have the visual effect of a portal. I think it simply teleports the player from one portal to the next. We are trying to find a way to have seam-less portals, like we see in Portal games.

Let us know if you come across any other video/tutorials/articles related to this.


Hi, News ?

He shows a pretty good portal here:

yes but there isn’t tutorial …

Please make a tutorial for this. Nice to hear that someone solved projection matrix making and some issues related, but nonprogrammers are just helpless to look at these unspecific explanations.

Hey everyone. i thought I’d just hijack this thread with my approach - which has one massive flaw.

What i am basically doing is spawning an “outsourced” camera with a Cap2D at the same spot as Doorway “exit”. I then change the relative position to Doorway “exit” to the same as the player is to Doorway “entry”. The rotation achieved by using “Find look at rotation”.

Now my camera is obviously moving too far back, leading to the doorscreen showing the back of the exit portal.

I have tried to adjust for this by fiddling around with the FoV settings, but while I can limit what the camera sees in this way it also automatically “zooms” the whole thing in.

Any suggestions?


I’m very interested by this feature and I tried to do this too . :stuck_out_tongue:
Unfortunatly I’m a beginner with programming and blueprints … :frowning:
But I’m curious! :stuck_out_tongue:

Before I found this post, I already searched some informations about the seamless portal transition.
So, maybe everybody in this thread is already familiar with this … But I just want to help :

The team of the Portal game worked on an other game with this feature before Portal. The name was Narbacular Drop (Narbacular Drop | DigiPen). In this website, i found something interesting in the pdf named " Technical design document" at the 19th page. This is a short describing of the methode they used :

"Portal Effect
The creation of our portals takes place with some extremely simple trickery along with a lot of
tedious things to make it work well.
Essentially, a portal is just a textured quad. But the contents of the texture are dynamic and the
texture coordinates change based on how you’re looking at the quad.
To create the contents of the texture:

  1. Convert the current camera position and look vector into coordinates relative to the portal.
  2. Find this position and rotation in relation to the portal’s exit.
  3. Move the camera to the point and rotation found in step 2.
  4. Render the scene while culling all objects between the camera and the portal exit.
  5. The render surface is now the source texture for the portal and the camera should be moved back
    to where it was before step 1.
    To render the quad with the proper texture coordinates:
  6. Convert each coordinate into screen space.
  7. Copy the normalized screen space x and y components into the u and v coordinates of each vertex.
  8. Render the quad. "

I’m working step by step, and my first step is already a problem :
For now, I just tried to create a “furtive quad” ( a plane with the exact image of the background) . Ideally, if I walk trough the quad, I should see absolutely nothing special happened…
Into the blueprint of my quad :
I get the relative position of the player camera, and set its position to a 2DsceneCapture, but I always get a position offset… why ?

ps : I know …the " furtive quad " is the most stupid feature in a video game ! xD But i think it is the most important step to get a seamless portal transition.

Hello all,

I have the majority of this figured out (albeit very buggy). I’m using a similar method of finding the camera’s rotation, but I’ve also included a way of (mostly) correctly finding the right field of view of the SceneCapture2d. By using the law of cosigns, and knowing the portal size, we can draw vectors to two sides and find the angle from there. This has lead to some odd distortion when up close, likely a result of the angle estimation I used. I’d be interested if anyone can fix this, but for distant portals I think this method is workable.

[video]Portal WIP - YouTube

*OP and BP correlate to the orange and blue square frames in the world. And I know there’s a lot of extra fluff in there, I’m pretty new to blueprints/programming in general lol.

I have been searching for a while and eventually found out this channel. It’s not my channel, but I believe it explains how to do what you guys are looking for :smiley:

Unfortunately they only show how to setup a basic portal, but missing the part of creating realistic visuals (different camera angles etc,) for the portals.
I’m still looking for help to get this done.
The SceneCapture2D solution is not very performance-friendly…

Yeah… ScreenCapture2D will eat up a lot of your processing power but might still be the best way to work if you use it to move parallel to the player… I got all that set up … but the problem I’m facing is, that i need the captured texture to be projected onto the “plane” from the players view… and I cant figure out how… Can anyone help with that?

Well ok… finally figured it out by myself… It was just one little node I actually allready looked for but couldn’t find, because I did only know what it does, not what it’s named…
I will put a link to a project with a working portal (BluePrint). I’m quiet new to any game engines so I had a hard time finding all the options.

There are a few things to mention:

  • This portal has the 1 frame lag which is almost not noticable when you walk but is pretty obvious if you turn the camera around
  • Sometimes it won’t only teleport you once, but multiple times causing you to land somewhere completely else… I couldn’t yet figure out how to fix this problem… It seems like the actions are passing multiple times through a branch before the next node is called… (switching the variable used in the branch from true to false…)
    But at the same time it seems, that the bug is more likely to happen if you hit the portal while you also hit the wall next to it… so it could be caused by wrong collision settings… If you have any idea on how to fix this Problem feel free to tell me… I’m curious.
  • Most of the time you walk through the portal there is a visual effect like a flash just in the moment when you hit it…
  • I created a portal based on my needs, so it’s 2 portals in one blueprint class. If you want to only have one blueprint with one portal and wish to set the portal you will teleport in the settings of placed portals, i suggest you to watch the video mentioned… They create such portals in their videos… but their visual effect isn’t the one you are looking for, so just use their way of teleporting and my way of creating the Portaltexture :wink:


Thanks!! :slight_smile:
I’ll check it out later.

No problem :smiley: I had the same problems as most others here … so I can really understand whats going on xD

If anyone needs some help to recreate this project just ask :wink: