Portal Rendering WIP

Hi All,

I would just like to share my latest experiment, for one of my projects I require the need for portals to simulate Non Euclidean style rendering. I was not happy with the Scene Capture 2D approach as this introduces a bad delay. So I went about modifying to the engine rendering code to support rendering portals directly through the use of the Stencil Buffer. These are my results:


Movie Clip:

Various shots from in the editor showing the portal geometry and normals/scene depth:


The good thing with the approach is it allows light and shadows to actually pass through the portals. Right now only light does, I have not implemented the portals to the shadow rendering pass as of yet (That is why there is no shadows).

Also as part of the portal rendering, I built a render layering system so that the destination can be completely hidden from the main render and only visible through the portals. The below screenshot shows a shot from in editor where the room is actually placed:


All the objects of that room are in render layer #1, so when changing to Game mode, only render layer #0 is shown, making the room dissapear, but still visible through the portals:


I plan to implement more control over render layers, using volumes to control the render layer of large quantities of objects without having to set it manually. The advantage of the render layers is being able to specify that only certain objects get rendered in Scene Capture 2D render targets (more control than just specifying static meshes, skeletal meshes, etc.)

Below the render targets show only objects in render layer #2 (Portal window in 1st screenshot, and Table and ball in second screenshot). While the main scene shows all layers:


Current limitations are:

  • Various passes, such as Shadows, Translucency, Particles do not work yet, working on that
  • Portals must face the same direction as the destination portal, mainly because Im not very good at rotational math.
  • Occlusion culling doesn’t work at all, so is disabled during portal rendering (So only Frustum culling). Working on a solution
  • Nested portals do not render yet, once you enter they will render
  • Objects can only be in one render layer at a time. Will be improving this to allow objects to be in multiple layers.

Looks really cool man.

Awesome approach man!

Any plans to get this into main branch? Plugin? It’s definitely a neat feature.

Thanks guys.

Well the plan would be to eventually submit to main branch as it cannot be in a plugin (too much rendering changes). But requires a lot more polish before that can happen.

A new update, working on movement through portals, still a bit of clipping occasionally. Still no nested rendering of the portals, so portals inside portals will appear unrendered

About the delay when using Capture2D:
Tom Looman and I worked on Portalrendering on our own seperately using Capture2D. He told me about the TickGroup, which allows you to specify that an actor ticks AFTER all physic updates have been done. Because before updating the portals viewport, everything else must have moved.

Interesting, altho the issues with portals using scene capture 2d is more than just the update rate, lighting cannot influence the area inside the portal unless its duplicated, with the above method I can place lights that will light up the portal area, as well as cast shadows into it. At the moment its a bit buggy, mainly as I have not changed the code to select which lights belong to which layer. Also theres usually a discontinuity between the two rooms, especially with screen space reflections, with the above method, its seamless.

Good work man! Cant wait to see the finished project!

Any news on your Portal rendering?
I’m currently trying to achieve something similar but i don’t know how to do it.

Could you in theory use your portal system to render the reverse of a room, for example as if there is a mirrored wall or such?

Would be possible with the use of the Stencil Buffer.
I saw someone doing it on youtube a few days ago, but not for Unreal.

It’s far more complicated in Unreal because the Renderer is so complex.
I really don’t know where to begin and get access to the stencil buffer.

btw… I created a thread for this:

Thats Slick!

How’s the portal rendering looking? Are there more updates?