One way viewpoint door possible in code?

Let me begin first hat i am not new to c++, but i am still quite new to the unreal api so if throughout this post i make mistakes please bash me so i may learn.

I was wondering if anyone had any ideals on how to make a single viewpoint door or if that is even possible (or if my terminology is even close to right). Basically imagine there is a free-standing door in the middle of a plane with nothing behind it, you can walk behind it and just see the backside of the door. If you open the door it leads to a staircase and you can walk down the staircase yet if you open it and walk around to the back of it, you just see the plane you and the door are already standing on. You can walk through the back part of the door and go nowhere technically but if you turn around you see the staircase again. One way viewpoint is the best terminology i can think of for this.

Question is what would be a decent way to implement this in code if it is actually possible?

Is this what you’re after? Unreal had Portals before Unreal 4, but they appear to have been taken out.

Unfortunately I don’t recall seeing any decent implementations in Unreal Engine 4. It’s a shame because there are a lot of modern games using similar features, such as Portal and Antichamber. (Written in UE3/UDK)

I did this in UE2 by using the stencil buffer to draw the portal over the main scene, and I think that is the standard way of doing this no matter what the engine is - given how heavily the stencil buffer is used by the engine though, in both UE3 and UE4, doing this would probably require expert knowledge of the internal rendering system, and a lot of customization, in order to make it work.

Disclaimer: I know next to nothing about working with the rendering system :wink: though this would make for a lengthy/fun and highly educational project.

Yes thats the most efficient way to do it (as far as I know). However the physics is still a problem. If you only need to allow the player to go through such a door, then a teleportation could do it. But if you need physical objects to respect this door (like portal), then things are much more difficult.

I had some success in recreating the visual effect of a portal using just blueprints. Here is the demo and scene setup

Scene setup:
However it has a heavy hit on performance and a 1 frame delay whcih is very noticeable. I did not work on it much (I did that in less than 2 hours) and never touched it gain.

Ya I did something like that in early UE3 days with the SceneCapturePortalComponent, which is a good way to approximate it in UE3/UE4 - but yes, render targets (especially at high resolution) are quite heavy on performance :slight_smile:

Way back in 2006/7, I nearly had a fully working UT2004 ‘portal gun’ mod done, before Portal itself came out :wink: (had to nix it though, as wasn’t allowed to release my rendering engine customizations)

This is actually something I’ve always wanted to play with in UE3/4, but have never taken the time to play around with learning the rendering system well enough to do it - would be interesting to hear what someone experienced with the rendering system, would have to say on it.

The physics side of it is indeed extremely difficult - I never looked at transitioning ‘through’ the portal, just made it teleport instantly - that itself would be another big task, requiring expert knowledge of the physics/collision internals of the engine (though I may be overestimating how hard that bit is).

The fact that i got so many replies in so little time makes me glad i invested into UE4, even if it is just for learning. Thanks everyone!

I was hoping i could possibly implement it just via calls to engine, but with all the talk of actually having to go down to the actual renderer code for modification i feel the equivalent of me being locked in an airtight casket and thrown into the bottom of the red sea, since i have never even managed to successfully make a simplistic renderer(those where dark times for me)

As a bash on myself, after deciding to look more into it myself and after just 5-6 minutes i came across this
Which backs up the requirement for renderer modification and the fact that portal functionality, while present in older engines, is not present currently in UE4. Primarily the response by mindfane.

Unless its either added eventually via roadmap, or given freely by a community member, i dont see myself as being able to implement this due to my limited renderer knowledge. Thanks anyone for contributing regardless!

On another note, has there even been a successful implementation of this with an orbit camera/over the shoulder 3rd person perspective? seems like the only things i see them implemented in are all 1st person.

I have been prototyping this concept for my game, still has a fair bit to go, and right now its in a very non distributing form, lots of straight renderer modifications. I hope to move as much as I can into a so that i can distribute to everyone, for free of course.

That would be awesome.
However could you give us some hints about how you are going o do it? Using stencils?

My original approach was to mask area covered by the portal door in inital render and then translate everything inside the portal’s frustum and render that getry into the masked area. However UE4 uses deferred lighting, which caused terrible lighting (the lights inside the portal area are discarded and all lighting is contriuted by lights around the player). So I dropped it. I am not that smart :frowning:

Anything new here? :slight_smile: