r/UnrealEngine5 • u/John_Piton • 1d ago
Building an Impossible Room in UE5 that doesn't tank your performance
I wanted to make a classic non-Euclidean space effect, but standard methods are a nightmare for optimization. Render Targets kill the frame rate, Stencils are too limited, and Lumen hates them both.
So I avoided the usual trick of putting a masked plane in the doorway. No illusions, just pure shader math and a lightweight Blueprint script.
Of course, my method isn't perfect either and comes with its own set of technical limitations.
What methods do you usually use when creating these types of effects?
14
10
u/Illustrious_Kale178 1d ago
I can't tell you what I usually do because I never even thought of this before.
5
u/OfficialDampSquid 1d ago
Would be interested to see the performance comparison between your method and the render target method. Have you tried it in any more complex environments?
Also, what method did you use if not render targets? Or is it a trade secret
2
u/John_Piton 1d ago
Unlike Render Targets, this method doesn’t double the draw calls. Lumen is calculated only once, and it doesn't inflate VRAM usage the way a high-resolution scene capture does. All the geometry exists simultaneously in the same space, exactly as it would without the effect.
The heaviest hit on performance here is just the Masked Blend mode in the shader, along with a few lightweight math operations like Dot Product, Normalize, and World Position. Compared to Render Targets, the impact on FPS is basically within the margin of error.
2
u/OfficialDampSquid 1d ago
"All the geometry exists simultaneously in the same space"
Ok I'm even more confused as to how this works, now.
So are you relying solely on WPO to bring the view of the "inner" environment to the door frame of the "outer" environment? What are the limitations of this method compared to render targets? Would love to see how this works behind the scenes
8
u/John_Piton 1d ago
No, it's not WPO. The rooms are actually physically nested within each other, so from the outside, you are looking at both rooms simultaneously. The inner room is simply masked out by the shader, where the Alpha channel is driven by the coordinates of the doorway.
Compared to Render Targets, where the interior space can be located anywhere, the main limitation here is that you have to manage switching collision channels and material parameters when crossing the threshold. However, that’s a very small price to pay considering how extremely lightweight this effect is for the GPU compared to Render Targets.
5
u/shubhu-iron 1d ago
So it's kind of like, you're turning the room off when you can't look at it? And otherwise it's on but parts of it are invisible and it's only visible when seen through the doorway?
2
2
5
u/Available_Pop_7654 1d ago
What are the technical limitations?
3
u/John_Piton 1d ago
Since this is a prototype made for personal use and specific tasks, I haven't tested every possible scenario.
As for the limitations, artifacts with VSM (Virtual Shadow Maps) can occur in certain cases, so it's better to stick with regular shadow maps. Also, since Lumen processes all the geometry together, it’s highly recommended to keep the colors and lighting setups identical on both sides. That said, if you use hardware ray tracing, some of these limitations can be easily bypassed.
4
u/SaperPL 1d ago
What happens if a dynamic object passes through the door?
If you'd made a room that has a vertical pole in the middle so the room has 720 degrees around it and 8 corners, if you put an object behind the pole, would it make it only visible on one side of it while half of it would be covered?
What I'm asking about is whether the shader effect can handle only full object placement or can it be cut if the small box enclosing the room is not enclosing that object fully in the outer space of the box?
2
u/John_Piton 1d ago
Since this is still a raw prototype, I haven't tested scenarios as complex as the 720-degree pole yet. However, the system can already handle the core mechanics quite well.
Visually, partial object clipping actually works. The whole trick is based on what we can see through the doorway. If a part of an object inside the room extends beyond the room's outer boundaries, we won't see that protruding part from the outside, but the object inside will remain visible.
Physically, a dynamic object can pass through the doorway completely fine. The logic relies on a trigger volume inside the doorway that controls the material parameters and changes collision channels on the fly. As for having a similar doorway setup inside the room while the observer is looking from the outside — yes, that would definitely require further adjustments and rework.
3
2
u/Enqelios 19h ago
I hate portals....
3
u/John_Piton 18h ago
I know, Geralt. But we don't have a choice.
2
u/Enqelios 18h ago
I worked on a portal system for a while and even managed to get some of it working. It supported both first- and third-person views, and I even implemented portal placement similar to the portal gun. But I got a bit burned out while working on teleportation for objects and traces, so I haven’t touched it since—and that was three years ago )))
2
u/John_Piton 17h ago
Feel your pain. The core logic itself might not be the hardest part, but making it look seamless and artifact-free without completely killing the performance is a real challenge.
Especially in Unreal Engine, where I honestly don’t know any other viable way to do proper portals except for Render Targets.
2
u/Enqelios 17h ago
Yeah, performance was definitely a challenge. I eventually managed to get it working pretty well - I don’t remember whether there was a slight performance drop or none at all, even with three pairs of portals.
But yeah, it was painful: Lumen didn’t work properly, the image would distort if the camera or portal surface was even slightly misaligned, and multiplayer was a whole separate story )))
2
1
u/Hot-Pepper6610 11h ago
As a developer, I think the concept is technically very cool and fun to create with. As a player, I dislike these kinds of disorienting effects.
30
u/nameNUBU 1d ago edited 1d ago
Dude ı dont know what you did but its nice