top of page

Development Update - Real Time Mirrors

Easily, by far, getting mirrors working has set me back more than anything else. I've never implemented AI before and I found that easier. So after much grief and optimisation I get something working fairly well on my machine. There was a significant frame rate dip but it was within acceptable range on my machine. I had my fingers crossed that it would be acceptable on machines of a lower spec. Boy was I wrong.

Real time planner reflection mirror pictured above, apologies for the darkness.

I tried 2 types of real time mirror solutions. The first (pictured above) was a planner reflection. This hit performance quite hard. The other was a 2D scene capture updating every frame and moving in relation to the player. This hit performance harder than the planner reflection.

The main problem with the way Unreal Engine handles it's real time reflections is that its rendering the scene twice. Once for the players view and once for the mirrors view. This means you can take your frames per second (FPS) and cut it in half more or less. So if you're getting a consistent FPS of 120, perhaps this solution would be fine. Infliction uses dynamic lighting and shadows however giving me around 100 FPS. That's still very optimal and real time mirrors generally give me around 40 to 60 FPS on my machine which is acceptable for this type of game.

After testing on lower spec gaming rigs though I saw a consistent FPS of around 60 which is good, but the mirror dropped to a whopping 18 FPS. This is completely unacceptable which lead me to investigate other options.

SSR or Screen Space Reflections is what Unreal Engine uses by default. These reflections aren't expensive and look decent. The problem with using SSR on a mirror is that it can only reflect with the player can see. This means that shower behind you will not show. Infact it's replaced with a black void. This option is also not something I can use.

I had one last ditch effort. Something very simple. I took a cube capture of the room and plugged the cube map from that in to a reflection sphere. The reflection is a static image, the player can't see themselves but I'll just grime the mirror up. This option also maintains a 90 to 100 fps depending on whats going on.

Static mirror without real time reflections pictured above. Note the missing player.

It's not the perfect solution and I'll miss out on being able to have scares happen behind the player using real time reflections but there are other ways to accomplish this. Taking screen capture cube maps of an event and switching the textures like a flip-book might work but I fear that is far to much effort for what is a very small aspect of this game. For now, the static mirror has the desired effect and my performance is well above what it needs to be for the time being.

bottom of page