How it is done:
Basically I created 4 things:
- A Render Target which has same resolution as main camera output.
- An unlit material which uses the above render target. The ‘Screen position’ node is given as input for UV pin. (this will clip-out unwanted areas of the target)
- A blueprint named BP_Portal_Entry. This is the door that you want to get into. It is very simple setup. All it has are two static meshes. One is the door frame. Second one is a plane on which the material from step2 is applied,
- A blueprint named BP_Portal_Exit. All the logic is done here. It has a DoorFrame as a static mesh component. Under it we have an Arrow (not needed), and the arrow has a SceneRender2D component. This component is set to render to the Target I created in Step1. The Event graph is shown in the image.
Each tick, I calculate the relative position and rotation of the active player and his control rotation with respect to Entry portal. I use these values to set Relative position and rotation of the Arrow component in Exit portal. (the arrow is not needed. I put it there so that I can see if the orientation and position are correct). This in effect moves and orients the SceneCapture compoenent.
This is not an ideal setup. Many things are hardcoded. Ideally the logic should be moved to Entry portal whcih should hold a scenecapture comp. This was we could have multiple Entry portal to be linked to the same Exit portal.
Render target is too big. But only a fraction of it is being used most of the time (only the area within the door frame). Essentially we are rendering everything twice.