Partial rendering of an actors at multiple locations (for a portal system)

I am currently working on a portal-like system in which an actor would be able to

  1. See the the world from the perspective of the target portal on the surface of the source portal
  2. Enter through the source portal
  3. Be teleported to and exit from the target portal
  4. While in the process of being fully teleported to the target portal, the actor would progressively disappear from the source location and progressively appear at the target location

While I was able to implement the portal rendering and the teleportation mechanism using similar techniques to those shown in this tutorial, I couldn’t figure out how to progressively make the actor disappear from the source and appear at the target.

Basically, let’s suppose that my actor looks like the following:


Let’s also suppose that the two portals are set up as follows (with the source portal being on the left and the target being on the right)


If this actor is mid-teleportation between the two portals, I would like it to be rendered as follows

Finally, here’s an animated illustration of the desired effect:

How can I achieve such an effect using Unreal Engine 4 ?

To elaborate a little bit on my question and especially the “Partial rendering of an actors at multiple locations” title of this thread: I was thinking that such an effect might be achieved by:

  1. Partially hiding the Actor’s mesh (or meshes if, for example, the actor is a Pawn that has multiple static meshes that have to go through the portal) past the location of the source portal
  2. Simultaneously rendering those hidden sections of the Actor’s mesh(es) at the location of the target portal

However, I don’t know whether such a procedure is possible in Unreal (and if so, how I would implement it).

I’m open to both C++ and Blueprint-based solutions.

Two different actors.

When you begin touching the first portal, duplicate the actor at the second portal on the opposite side, offset as if to appear that it is just exiting.

In both cases, you will need to use materials to hide what ever parts are on the wrong side of the portal.
I am not great with materials, so while I know its possible, I can’t tell you how :frowning:

Based on a video I’ve seen for a similar project in Unity ( it seems like one way to cut off part of the mesh would be to adjust the clipping plane so that it is aligned with the door when you render. However… I’m not really sure how to do so in Unreal, and I can’t find much on the topic.

Another approach would be to add a custom clipping plane via the material shader. Basically, you would need to enable Opacity Mask on the material (1.8 - Opacity Mask | Unreal Engine Documentation) and pass in white or black as the opacity depending on which side of the clipping plane the point lies on.

Here’s an older video showing a similar effect, albeit with a sphere:

Thank you all for those initial answers!

I see what you mean.
However, I was hoping to avoid duplicating the actor: As a UE4 beginner, I find this solution particularly tricky to manage and rather error-prone, especially if the actor has some kind of dependency to or is somehow referenced by other actors.

After a bit of research, I found this tutorial which shows how to do that.
While certainly useful, I think that this technique solves only half the problem – i.e. it allows partially masking the actor at the source portal and/or partially showing “another actor” at the target portal, but it doesn’t partially hide the actor at the source portal while simultaneously partially showing “the same actor” at the target portal.

When the actor is completely though the portal then replace the newly created actor with the one going into the portal.

If you insist on using the exact same actor, you might wanna try using world position offset (WPO), I haven’t build this, so I can’t assure you that this will work, but I can tell you for sure that it will not be trivial, so I would highly recommend you go with the two actor approach.

What WPO does, is it changes the position of the vertices of the mesh (that’s how the wind in the trees work for example). Basically you would check for each vertex of the mesh whether or not it’s beyond the entry portal plane. If it is, then you would change it’s location to the second portal.
First Problem: WPO will not slice the mesh along the portal. Therefore you will then have to check for every pixel whether it is between the output plane of the first portal and the input plane of the second portal and if so, then mask them out (so set the opacity to 0).
Second Problem: You want to move the vertices to the second portal in the same relative position they were in the input portal. That will be easy if both your portals have the same normal, if not you would need to transform between those two local coordinate systems.

You also might wanna keep in mind, that WPO is completely cosmetic. Since the GPU render thread happens after the CPU game thread the CPU will never know about this. Same for the two actor approach using masking. The collision of the mesh for example will still be the same, even if part of the mesh is not visible.

Again I would highly recommend you go with the two actor approach :slight_smile: