Announcement

Collapse
No announcement yet.

Simple Portals

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

    [TUTORIAL] Simple Portals

    Hi!

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

    Wiki page:
    https://wiki.unrealengine.com/Simple_Portals

    Project files: (old)
    https://wiki.unrealengine.com/File:SimplePortals.zip

    Project files on google drive:
    https://drive.google.com/open?id=1QF...7ioSvxz6qsyJSo

    Example project contains:
    1. Examples for simple camera-screen setup:
    Click image for larger version  Name:	screens.jpg Views:	1 Size:	131.3 KB ID:	1504373

    2. Examples for simple mirrors:
    Click image for larger version  Name:	mirrors.jpg Views:	1 Size:	133.8 KB ID:	1503944

    3. Examples of simple portals:
    Click image for larger version  Name:	portals.jpg Views:	1 Size:	106.1 KB ID:	1503945

    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
    Last edited by redbox; 07-20-2018, 11:03 AM.
    Rocketeer

    my portfolio
    my youtube

    Camera Volumes System
    Procedurally Instanced Meshes
    Simple Portals
    Water Flow For UDK
    Setup Swarm

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

    3. 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.

    4. 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.

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

    6. 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.
    Click image for larger version

Name:	clip_replace.jpg
Views:	321
Size:	21.8 KB
ID:	1128483
    Last edited by redbox; 07-20-2018, 11:02 AM.
    Rocketeer

    my portfolio
    my youtube

    Camera Volumes System
    Procedurally Instanced Meshes
    Simple Portals
    Water Flow For UDK
    Setup Swarm

    Comment


      #3
      This is a fantastic tutorial,
      Any tips to have it work in VR?
      JcInventory, a Jigsaw Grid based Inventory designed in UMG and blueprint

      Comment


        #4
        Great work redbox

        Comment


          #5
          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
          https://drive.google.com/open?id=1QF...7ioSvxz6qsyJSo

          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 (https://forums.unrealengine.com/comm...rtal-mechanics)
          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.
          Rocketeer

          my portfolio
          my youtube

          Camera Volumes System
          Procedurally Instanced Meshes
          Simple Portals
          Water Flow For UDK
          Setup Swarm

          Comment


            #6
            Thank You, Redbox

            Comment


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

              Comment


                #8
                Originally posted by cyclopsys View Post
                Has anyone created a VR portal? Any tutorials out there?
                Check FTC Free Portal Mechanics thread https://forums.unrealengine.com/comm...rtal-mechanics
                Rocketeer

                my portfolio
                my youtube

                Camera Volumes System
                Procedurally Instanced Meshes
                Simple Portals
                Water Flow For UDK
                Setup Swarm

                Comment


                  #9
                  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!

                  Comment


                    #10
                    Originally posted by Fatorice View Post
                    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.




                    Rocketeer

                    my portfolio
                    my youtube

                    Camera Volumes System
                    Procedurally Instanced Meshes
                    Simple Portals
                    Water Flow For UDK
                    Setup Swarm

                    Comment


                      #11
                      Hey,

                      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. :P
                      Last edited by FreshDumb; 05-16-2019, 04:49 AM.

                      Comment


                        #12
                        FreshDumb , great work on fixing this! Thank you.

                        Comment


                          #13
                          Originally posted by FreshDumb View Post
                          Hey,

                          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. :P
                          thank you!
                          Rocketeer

                          my portfolio
                          my youtube

                          Camera Volumes System
                          Procedurally Instanced Meshes
                          Simple Portals
                          Water Flow For UDK
                          Setup Swarm

                          Comment

                          Working...
                          X