This experimental project went a little further. So, here is small update.
Changed some text and pictures.
Changed description of example project.
Example project (updated to UE 4.15.3):
Added blueprint function library with basic math functions for portals operations (BP_PortalsFunctions).
Added PlayerCameraManager class to handle camera transformations.
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.
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.
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.
Added material function MF_PortalPlane, that used as mask, to replace inner portal surface with color or texture. See material “M_PortalReplacement”.
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.
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
Fixed mirrors material.
Added base class “BP_BaseRenderSurface” for all provided actors. It contains basic functions for initialization of scene capture, optimization checks and so on.
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?
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.
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.
Really nice tutorial you made there.
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.
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.
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.
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.
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.
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.
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.
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.
Hello, very good plugin.
How can I use the BP_Mirror to function as a Window and as a one-way portal, that is, I don’t need any other Target-portal.
The BP_Mirror works well when moving the camera, there is no offset, and the environment is scaled well, but if I turn the mirror StaticMeshComponent (Yaw=180) in the opposite direction to the SceneCaptureComponent2D (Yaw=0), I do not get the same effect.