Seamless Portals

Hello !

I wrote a new tutorial, this time about creating seamless portals. :slight_smile:
I cover how I did it as well as some issues I encountered and how I managed to fix them. You can read the article over here : https://wwwā€¦fr/blog/2019-03-cā€¦nreal-engine-4

Here is a little demo of the final result :

Let me know what you think or if you have questions !

The clarity of the blog post is impressive. I recognized your user name, but couldnā€™t remember from where. After reading this article, I realized I also read the ā€œTrue First Person Cameraā€ one a while ago. Easily one of the most professionally written blogs I came across.

Bookmarked.

Awesome! Thanks!

Thank you very much, I really appreciate your comment. :o

Good tutorial!

Iā€™ve used custom PlayerCameraManager for my portals system, to calculate camera updates with overriding UpdateCamera() in it.
It was useful because you can set bGameCameraCutThisFrame right there to handle culling issues, without creating custom LocalPlayer class.

Hooo ! Thatā€™s good to know !
I guess I went too deep too soon when I started looking into the culling issue. :slight_smile:

Bookmarked, very well done!

Juste had a very quick look at your Tuto.
Very nice work and well explained.

Thank you very much !

Hi!

Very nice Tutorial, thank you very much for itā€¦ Iā€™m a beginner in UE4, so Iā€™ve some question and I hope you can help me out:

  • You used a C++ PlayerCharacter/PlayerController. Can I also implement your system with a Blueprint PlayerCharacter?
  • How exactly did you set up the mesh? I tried it, but only the centered ā€œpointā€ offsets, not like yoursā€¦

Iā€™m looking forward to hearing from you!
Best regards

Sorry for the late reply.
Itā€™s likely possible with a blueprint Character, you will just have to be sure everything ticks in the right order. For the mesh, do you mean the portal mesh ? You have to make sure the vertices of the mesh are in the right position in the UVs, otherwise the masking (and therefor the offset) wonā€™t work properly.

Hey . Tried accessing your tutorial for the portals but the link is broken. Getting site canā€™t be reached errors :confused:

Everything seems to works fine on my end and my website host is not known to have downtime or traffic limitations. I would suggest to try again.

Okay thank you! But Iā€™m not sure how to cast to a blueprint Character within a C++ Class, maybe you can give me an example or an code snippet? With the mesh I will check it out, thank you very much for your great tutorial and your help! :slight_smile:

You donā€™t need to, just access the Character that is spawned by your Gamemode. You just need to be sure your Blueprint class is based on the C++ class that defined the few function necessary for the Portals. (C++ canā€™t call Blueprint functions that it doesnā€™t know, as far I know.)

Great tutorial. Thank you.

Thanks for sharing this amazing work!
Can you share a small example project?

Merci pour ce tuto! Un bel exemple de partage constructif!:slight_smile:
Est il possible de que tu partage un petit projet modĆØle sur ton site, ce qui permettra de mieux apprĆ©hender le tutoriel pour ceux qui ne maitrise pas encore bien le code mais seulement les blueprints?

I wonā€™t share any files, only the written tutorial. The main reason is because itā€™s too much mixed with my own project, it would take quit ea bit of time to create a clean and simple sample project.

Is it possible, that you share the Portal Mesh with us? We canā€™t create it, that it looks like you provided. When I test it with the Material, it looks very confusing (see attachements).
I donā€™t know, what we are doing wrongā€¦ I canā€™t find the ā€œSplitComponent V2ā€ so I used ā€œMask Componentā€ with Channel set to ā€˜Gā€™.

Itā€™s doesnā€™t work because the UVs are incorrect. I added to the article the following image which hopefully will clarify how the mesh works :

https://wwwā€¦fr/blog/wp-content/uploads/2019/03/portal_uvs.gif

There was as well an error in the way I described the the mesh UVs in the article, so I fixed that as well (I inverted what was at the top or the bottom for the UVs).

SplitComponent is a custom node that I made, it works the same as the Component Mask node indeed. I added a mention about it in the article.

@ Interesting stuff! And fantastic write up, I generally prefer a well-written doc to a video.

I have a fairly simple but solid portal system on the marketplace - pure BP, but looks like it works on a fairly similar set of principiles to your tutorial, with a few pros and cons.

Your jump-cut soultion to the incorrect frame after exiting a portal is fantastic - my solution is indeed to disable occlusion culling. As you mention, there does not seem to be a command for it, but there is an option in the project settings, which requires restarting the editor. This, along with enabling the global clip plain, is the reason I distrib as a project instead of asset set.

Also interesting to notice bGameCameraCutThisFrame in the player camera manager is BP readonly, but the bCameraCutThisFrame in capture2d is BP R/Wā€¦

Itā€™s also good to see the extra attention you are taking to minimise the performance impact on scenecapture, and using the players projection matrix (where I only grab the players FOV)

Also interesting to see your setup with the portal mesh and offset shader, I have an ā€œinverted boxā€ with ā€œinternal finsā€

On the upside of my setup, it is fairly generalised, and will create a ā€œvisual cloneā€ at the other end of the portal for an actor containing static/skel meshs

I hope I am wrong, but think we are both not quite far from VR portals without 1-frame lag - have a look at the rendering section of the engine, the HMD motion is done as late as possible, it seems planar reflections are a ā€œspecial caseā€ in being performed after HMD motion, and some engine modification is needed to get around thisā€¦

Right now Iā€™m starting to look more seriously into a setup more along the lines of portal/portal2, using stencil buffer to lower both processing and ram requirements - which would also make recursive rendering more practical.

I have some ideas on how to do a decent physics setup, allowing portals to be placed against a wall, and for the ā€œvisual clonesā€ at the other end of a portal to have functional physics interactions, but really need to do more research in this area. With luck, it could end up as a more general system than in the portal games - but I donā€™t expect so.

edit: I just submitted PR to allow setting cameracut in BP https://github.com/EpicGames/UnrealEngine/pull/5823 :slight_smile: