Download

Simple Portals

Hi!

I see that many people interested portals feature.
Here is small tutorial for you about.
Hope it will be helpful.

New project location:

New wiki (github):

Wiki page (old):

Project files (old):
https://drive.google.com/file/d/1QFsJCgAroXiFi6H3T37ioSvxz6qsyJSo

Example project contains:

  1. Examples for simple camera-screen setup:

    ](filedata/fetch?id=1504373&d=1532098895)

  2. Examples for simple mirrors:

    ](filedata/fetch?id=1503944&d=1532020307)

  3. Examples of simple portals:

    ](filedata/fetch?id=1503945&d=1532020307)

Old demonstration video:

Update 24/05/2017
https://forums.unrealengine.com/comm…876#post992876

Update 19/07/2018
https://forums.unrealengine.com/comm…76#post1503676

Update 02/02/2020
https://forums.unrealengine.com/comm…27#post1716627

Update 24/05/2017

This experimental project went a little further. So, here is small update.

Wiki page:

  • Changed some text and pictures.
  • Changed description of example project.

Example project (updated to UE 4.15.3):

  1. Added blueprint function library with basic math functions for portals operations (BP_PortalsFunctions).

  2. Added PlayerCameraManager class to handle camera transformations.
    Player character:

  • Added advanced teleportation example that works smoothly with camera/character transition through portal;
  • Added copy of skeletal mesh component, that used to visualize advanced teleportation;
  • Added ability to teleport through uniformly scaled portal, but needs to scale some more parameters;
  • Added simple PhysicsHandleComponent setup to manipulate physics objects.
  1. Added experimental physics actor class (BP_PhysActor), which can be teleported through portal. It also uses copy of StaticMeshComponent to visualize teleportation. It have few issues but maybe you can make some improvements.

  2. Added material function MF_ClipPlane, that uses world coordinates of specified clip plane to make material clipping through portal. Use it as opacity in masked/translucent material.

  3. Added material function MF_PortalPlane, that used as mask, to replace inner portal surface with color or texture. See material “M_PortalReplacement”.

  4. Portal actor:

  • Portals supports any scaling for basic portals math functions.
  • Portals supports uniform scaling for rendering portal view.

Note that for now teleportation setup is fully dynamic. So, theoretically, it supports moving/rotating/scaling portals. And it may be unnecessary if your game uses static portals.

Also, I tried to fix problem with portal surface clipping by camera near clip plane, using portal’s render target in post process material.
I’ve almost find formula for clipping mask, but suddenly I stuck with another problem - render target texture appears darker when used in post process material. I think it related to post process/HDR settings, but I don’t know how to fix it.
So in example project it’s disabled. You can enable it by connecting IsTrackTeleportation branch to Tick event in PlayerCameraManager class.
clip_replace.jpg

This is a fantastic tutorial,
Any tips to have it work in VR?

Great work redbox :slight_smile:

Update 19/07/2018

Somewhere after release of UE4.19, I noticed that mirrors works incorrectly - they become flipped on Z axis.
It looks that scene capture components no longer supports negative scale. Also I have done few improvements, so here is a new version of example project.

Project files on google drive

Example project:

  1. Fixed mirrors material.
  2. Added base class “BP_BaseRenderSurface” for all provided actors. It contains basic functions for initialization of scene capture, optimization checks and so on.
  3. Fixed rendering lag for Mirrors and Portals. Thanks to @FTC and his Free Portal Mechanics (Free Portal Mechanics - Released Projects - Unreal Engine Forums)
  4. Added “BPC_SurfaceTracing” component, to hold portals recursive tracing functions.
  5. Added new example materials, with distance fade instructions for rendering optimizations.

Wiki page:
For now, Wiki is disabled for editing due to upgrade process. When it’s done, I will update wiki page according to fixes and improvements in example project.

Thank You, Redbox :slight_smile:

Has anyone created a VR portal? Any tutorials out there?

Check @FTC Free Portal Mechanics thread https://forums.unrealengine.com/comm…rtal-mechanics

Hello!
Thanks for sharing your project, really awesome! But I figured out, that there’s a issue when you watch through a portal, which also watches a portal… Is there a possibilty to fix it?
For example:
|
Portal 1 Portal 3
|

                         |

Portal 2 Portal 4
|

The “|” is the Direction of the Portal. And Portal 2 is connected with Portal 4, Portal 1 with Portal 3. When I watch through Portal 2, I don’t see whats infront of Portal 1, I see whats infront of Portal 3, but in the opposite Direction.

Thank you!

Hello.
If you’d read wiki article, you should notice this case in Limitations section.

It is impossible to show one portal from one pair in another portal from different pair correctly, because all portals calculate their views according to player camera world position. So, portals always “think” that you look at them through player camera. Portal doesn’t know that you look at it through another portal or another camera.

Hey,

Really nice tutorial you made there. :slight_smile:
Used it in a project and got it to work pretty fast.

The only problem i encountered is that when you package the project the Portals don’t work any more and i didn’t find anything about that in the thread or in tutorials. :frowning:
First i thought the problem was in my implementation, but when i try packaging your example project, it produces the same bug.

Any idea why that may be happening and how i could try to fix it?

Edit: I didn’t really explain what i mean properly i now notice. :smiley:
And the Problem also occurs in Standalone mode. The portals show the wrong material and the console doesn’t show errors. It shows only the beige kind of material you see in the browser.

Edit2: Actually found the fix myself, so posting it here to maybe help someone encountering it too. @redbox Maybe it is of help to you too. :slight_smile:
In the BP_BaseRenderSurface class, in the function InitSceneCapture you get the Viewport size as a Vector2D. But when the project is packaged or in standalone mode, this function returns 0 because it is executed before the HUD is even registered to the Viewport.
First of all i changed the function to reference the owning player controller to always get the correct viewport and secondly i made the class delay 0.5 seconds before initializing to make sure the Viewport ist registered correctly. Then everything works perfectly. :slight_smile:
Hope this helps someone as it was a pretty big pain to find, but i am also pretty new to Unreal and find debugging packaged and standalone pretty tedious. :stuck_out_tongue:

@FreshDumb , great work on fixing this! Thank you.

thank you!

Awesome work!

Where is this functionality in the BPs? I’d like to adjust how the portals handle scaling and am having a hard time teasing out the dependencies.

Hello.
This is basic behavior of portal functions. How vectors converted into portal space and from it.
Here is PortalConvertDirection

and PortalConvertLocation fuctions

It using TransformDirection, InverseTransformDirection, TransformLocation and InverseTransformLocation functions that includes scale in new transform calculations.
There are their analogs in C++ that not using scale.

Additionally, player character handles teleportation itself.
Blueprint’/Game/GameMode/FirstPerson/BP_FirstPersonCharacter.BP_FirstPersonCharacter’
In function TeleportationAdvanced you can find how it changes self velocity, location, rotation and scale according to portal parameters.
Well, it is very basic example of how it should be handled, but I hope you will find it useful.

[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_182748_1580712331436_236”,“title”:“20200203_0844.jpg”}[/ATTACH]

Update 02/02/2020

Hello again.
Because UE wiki is dead, I’ve uploaded this project to github.

New project location:

New wiki (github):

This is final version of everything I had done in it with blueprints + partially migrated to C++ as plugin. But only partially.
If you need to use BP version only, just remove

  • Plugins
  • Source
  • SimplePortals.uproject_cpp_bkp

Redbox - Well I feel pretty stupid, it was staring me in the face the whole time. I’d completely forgot that transforms had scale built in. Thank you for taking the time to explain as well as the recent project update.

Friend, have you tried to turn off the Motion Blur and Use the FXAA instead of TemporalAA,I tried this and the portal looks more smooth now.

Good point, but anyway, portals texture must be filtered additionally. Ideally in the same way as original scene.