Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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 https://www.youtube.com/watch?v=F28NKqG7ce8, 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:

    Click image for larger version  Name:	cat.png Views:	4 Size:	188.8 KB ID:	1727346

    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)

    Click image for larger version  Name:	portals.png Views:	4 Size:	149.0 KB ID:	1727349

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

    Click image for larger version  Name:	split_01.png Views:	4 Size:	283.0 KB ID:	1727347
    Click image for larger version  Name:	split_02.png Views:	4 Size:	242.1 KB ID:	1727348

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




    How can I achieve such an effect using Unreal Engine 4 ?
    Last edited by e4c23ef5; 03-01-2020, 11:57 AM.

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

    Comment


      #3
      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
      Rule#21: Be polite, be professional, but have a plan to kill everyone you meet.

      Comment


        #4
        Based on a video I've seen for a similar project in Unity (https://www.youtube.com/watch?v=cWpFZbjtSQg) 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 (https://docs.unrealengine.com/en-US/...1_8/index.html) 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: https://www.youtube.com/watch?v=CkEueafOvF.

        Comment


          #5
          Thank you all for those initial answers!

          Originally posted by Kris View Post
          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
          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.

          Originally posted by smelnick97 View Post
          Based on a video I've seen for a similar project in Unity (https://www.youtube.com/watch?v=cWpFZbjtSQg) 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 (https://docs.unrealengine.com/en-US/...1_8/index.html) 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: https://www.youtube.com/watch?v=CkEueafOvF.
          After a bit of research, I found this tutorial https://www.youtube.com/watch?v=GO5zQ5tUUbM 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.

          Comment


            #6
            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.
            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

            Comment

            Working...
            X