User Tag List

Results 1 to 40 of 40

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

  1. #1
    0

    Question 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]
    I recently started using Unreal Engine 4 and was disappointed to see the removal of the UTPortal actor. I've tried experimenting with SceneCapture2D and depth buffers to get a similar effect, but the resulting view, while three-dimensional, lacks any sort of perspective detection and the view remains stationary.

    I essentially recreated the effect shown in this video https://www.youtube.com/watch?v=r5XAVy6wE-A
    It's certainly better than just a flat real-time 2d texture, but it is a far cry from what the UTPortal actor could do. Does anybody have any ideas?

    -Finkton


    Name:  64d99d7f8a0e860d7ffea6b36aea7768.png
Views: 6425
Size:  71.2 KB
    Name:  8d6b0f00a0f173123db0880fb9276103.png
Views: 5718
Size:  131.4 KB
    Name:  7457-blueprint.png
Views: 6778
Size:  328.0 KB
    Name:  1077741fcb7b18ff30d701288a2db94f.png
Views: 5663
Size:  38.3 KB
    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.
    Attached Images Attached Images  
    Last edited by Finkton; 06-01-2014 at 12:19 PM.

  2. #2
    0
    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.

  3. #3
    0
    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.

  4. #4
    0
    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.

  5. #5
    0
    I have been researching on this topic for a while.

    Played the portal games again and again for several weeks.

    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.

    Disadvanatges:

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

  6. #6

  7. #7
    0
    Quote Originally Posted by Smozius View Post
    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.

    Thanks

  8. #8
    0
    Hi, News ?

  9. #9

  10. #10
    0
    yes but there isn't tutorial ...

  11. #11
    0
    Infiltrator
    Join Date
    Jan 2015
    Posts
    11
    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.

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

    Name:  Portal Camera.png
Views: 4319
Size:  153.6 KB

    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?

  13. #13
    0
    Hi,

    I'm very interested by this feature and I tried to do this too .
    Unfortunatly I'm a beginner with programming and blueprints ...
    But I'm curious!

    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 (https://www.digipen.edu/fileadmin/website_data/gallery/game_websites/NarbacularDrop/). 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:
    1. Convert each coordinate into screen space.
    2. Copy the normalized screen space x and y components into the u and v coordinates of each vertex.
    3. 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.

  14. #14
    0
    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.

    https://youtu.be/BGHQiXqOmds


    Name:  BlueprintTest.PNG
Views: 4117
Size:  307.2 KB

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

  15. #15
    0
    Samaritan
    Join Date
    Jan 2015
    Posts
    126
    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

    https://www.youtube.com/watch?v=R-1eG-oP-CM
    If you want to see my UDK games, have a look at my website!

  16. #16
    0
    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...

  17. #17
    0
    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?

  18. #18
    0
    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 UpARiver 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

    ProjectFile:
    https://mega.nz/#!RsRhnDTA!tyIZM6wzvTCGu7AqkIJG_O1uYsNAXWcB94vDrIfss9g

  19. #19
    0
    Quote Originally Posted by Rechakos View Post
    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 UpARiver 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

    ProjectFile:
    https://mega.nz/#!RsRhnDTA!tyIZM6wzvTCGu7AqkIJG_O1uYsNAXWcB94vDrIfss9g
    Thanks!!
    I'll check it out later.

  20. #20
    0
    No problem 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

  21. #21
    0
    I'm really curious how it looks.
    I'll try to translate it into C++ when i get it working like I need it

  22. #22
    0
    I think it's pretty much the same result as in a video, which was posted before ( https://www.youtube.com/watch?v=Gt3NLTnCUTk ) expect mine works both ways... xD

    And I did some tests... it really seems like the face the the portal is overlapping with an object (or it seems to be enough to even just be inside the "Bounding Box" of an object) is triggering the multiple teleport...
    I don't know much about that but it still happens when i set that object to BlockAll and untick Generate Overlap Event in the Collision-Tab. I could really need some help with that...

  23. #23
    0
    Another thing I just saw that I missed is:

    The Resolution of the Texturetarget is constantly at 1080p.... If you use a different Viewport Aspect Ration (not 16:9) this causes a distortion on the Portal... there should be a way to set texture size to the viewport size... This way it would also use fewer perfomance (without changing the value by yourself) when you run the game at 720p...

  24. #24
    0
    Thanks for mentioning it.
    I already blueprinted something that automatically adjusts the resolution to aspect ratio of the Portal mesh

    I'm checking out your work right now...
    The teleportation seems completely off, but the visuals are awesome!
    Well done!

    I'm looking at the teleportation now...

  25. #25
    0
    That awkward moment when you have the perfect portal system but the code isn't yours to share

  26. #26
    0
    Quote Originally Posted by TheJamsh View Post
    That awkward moment when you have the perfect portal system but the code isn't yours to share
    Well.. thanks for saying it

  27. #27
    0
    @DennG well I guess what you mean by saying the teleportation is off is the bug i mentioned... I think I added a string value that prints out Entrance when you go through the first portal and Exit when you walk through the 2nd Portal.. sometimes the portals get triggered multiple times... and as it seems its caused by the walls.. (if the portals are completely free it works perfectly..) I couldn't yet find a way of fixing it...

    @TheJamsh and DennG Thank you both very much I appreciate it! Even though it has still things that have to be improved.. (the teleporting bug.... -.- I need it fixed... it's really annoying..)
    Also... if you want to show it to someone... just post this link.. I think the others here did most of the work.. the tutorial with the portalgun that I mentioned earlier really helped me getting started in UE4.. (it's actually the first time I've been editing anything in the blueprints..)

  28. #28
    0
    I'm happy to help where I can, maybe even write some code. In the end we had to use a custom render path (in C++) to get this working, with a different projection matrix on the capture actor. Without it, things would distort and it was practically impossible to make it 100% seamless. It was also quite expensive thanks to the Render Target, but switching off some items like AO and clamping the draw distance helped that a lot. The advantage however, was that in doing so we could also get it working with VR. (I say 'We' a lot in this sentence, but in reality it was a super-talented guy from EA who helped us out most of last year).

    There's a very crude example of it working in our Epic Gam Jam submission (Post #138 in the submission thread!) if you want to check it out. But it was kind of hacky in that example thanks to streaming levels etc. I'd like to have a proper go at it myself and see if I can squeeze some more performance out of it.

    In order to help make the teleporting more seamless, we also have a 'Manager' object that just tracks the players velocity constantly, and when they are 'just' close enough to the portal, it teleports them through in such a way that it remains seamless, but it's a balancing act of the current velocity of the camera and the distance from the portal to get it right.

    It's also first-person only atm, and if a portal tries to render another portal in it's capture actor, it'll just be black (as a safety to prevent overflow).

  29. #29
    0
    @TheJamsh
    I really like to do it in C++ and without SceneCaptures, but I don't have any experience with graphics programming. I only know a few things about render paths. Do you know tutorials or articles where I can learn things related to that? Or even give me a starting point.

  30. #30
    0
    I haven't got a clue I'm afraid. I also don't have the source for that to hand atm so I'll look it over again and try and find the key points and post here!

  31. #31
    0
    Quote Originally Posted by TheJamsh View Post
    I haven't got a clue I'm afraid. I also don't have the source for that to hand atm so I'll look it over again and try and find the key points and post here!
    Thanks for the fast reply. That would be awesome!

  32. #32
    0
    Sorry for double-posting

    @TheJamsh
    I found some interesting examples of portal rendering. It's not in Unreal Engine but in theory it should be the same I guess.

    OpenGL Portals: https://en.wikibooks.org/wiki/OpenGL_Programming/Mini-Portal (Source included on the bottom)
    Unity3D Portals: https://www.youtube.com/watch?v=5DKIP9N-OB4 (source code: http://www.noisecrime.com/unity/packages/PortalRoomCubeViaStencilsExample_u4.2.zip)

    Both are using stencil buffers to achieve the effect.
    Now it would be good to know how to integrate this into Unreal.


    Btw.. I've tested your Epic Mega Game Jam entry, but unfortunately the portal rendering was not visible :/
    Other than that it was awesome! respect!

    I would be so grateful if you could help me out with this.
    Last edited by DennG; 12-13-2015 at 05:47 PM. Reason: removed some ****

  33. #33
    0
    Quote Originally Posted by Rechakos View Post
    I think it's pretty much the same result as in a video, which was posted before ( https://www.youtube.com/watch?v=Gt3NLTnCUTk ) expect mine works both ways... xD

    And I did some tests... it really seems like the face the the portal is overlapping with an object (or it seems to be enough to even just be inside the "Bounding Box" of an object) is triggering the multiple teleport...
    I don't know much about that but it still happens when i set that object to BlockAll and untick Generate Overlap Event in the Collision-Tab. I could really need some help with that...
    I know it's been a while but I tested your blueprint in a project and found that same problem and managed to come up with a poor man's fix. It seems the problem has to do with the firspersoncharacter's capsule component hitting both the wall and teleporter at the same time and at strange angles, so all I did was replace the capsule collision component with a box collision component, and it works flawlessly now.

    Probably not ideal for everyone's purposes but it works for me, and it could shed some light on what exactly is causing the multiple teleport problem.

    Video for those interested
    Last edited by Skitt2501; 05-05-2016 at 04:52 PM.

  34. #34
    0
    Quote Originally Posted by Skitt2501 View Post
    I know it's been a while but I tested your blueprint in a project and found that same problem and managed to come up with a poor man's fix. It seems the problem has to do with the firspersoncharacter's capsule component hitting both the wall and teleporter at the same time and at strange angles, so all I did was replace the capsule collision component with a box collision component, and it works flawlessly now.

    Probably not ideal for everyone's purposes but it works for me, and it could shed some light on what exactly is causing the multiple teleport problem.

    Video for those interested
    Kind of off-topic but how did you change the capsule component to a box? This is essential for my current project.

  35. #35
    0
    Quote Originally Posted by Ascendancy View Post
    Kind of off-topic but how did you change the capsule component to a box? This is essential for my current project.
    I just went into the first person character blueprint, removed the capsule collision component and then added a box collision component, giving it roughly the same size and dimensions, as well as the same collision properties.

    Hope that helps!

  36. #36
    0
    I have researched the method on how to implement this effect myself, and I have finally figured it out. I think I've made a breakthrough,
    Hope this helps whoever comes across this topic again.

    Here's the tutorial:


  37. #37
    0
    Supercalifragilisticexpialadocius! (Think I spelled it correctly... have to pack up and run home from work right now).

  38. #38
    0
    It's SOOOO close to being perfect! Just TWO issues left to solve (aside from physics handling, that's a different beast)

    1. Culling everything between the virtual camera and the portal plane.
    2. Recursive rendering (probably only possible through trickery and not actual recursion)

  39. #39

  40. #40
    0
    Far out man! MasterOfDreams That is beautiful! I've been trying to get the seamless transitions (animating characters between 2 portals) and can't find a way to do so... I really have no idea how you got it working like that
    would it be possible to ask you for a tutorial on how you did it or example files? (if it's Ok with you )
    Thanks man!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •