July 23, 2018
In this second part of the tutorial, we’ll see how to find a solution to the problem analyzed in the first part so that we can improve the performances in the game in Unreal Engine.

Software: Unreal Engine 4.19.2
Plug-in: RenderDoc (free)
Hardware specs: CPU Intel i7-6900K (8+8 core) | GPU GTX 1060 6GB

In this second part of the tutorial, we’ll see how to find a solution to the problem analyzed in the first part so that we can improve the performances in the game.

In the part 1 of the tutorial we got the following results:

  • Frame: 15.18 ms
  • Game: 1.76 ms
  • Draw: 0.09 ms
  • GPU: 15.17 ms

One of the problems found were the Planar Reflections used in the scene. After optimizing the Planar Reflections, the new results are:

  • Frame: 11.44 ms
  • Game: 1.28 ms
  • Draw: 10.95 ms
  • GPU: 11.40 ms
Captured Frame Optimized

Immediately we notice that the frame has changed from 15.18 ms (~ 66 FPS) to 11.44 ms (~ 87 FPS), which is already a good improvement. Before going on with the optimization, let’s say something on the Draw value.

In the unoptimized scene, the Draw value was 0.09 ms (almost 0) while after the optimization it increased to 10.95 ms. Why? The Draw value keeps into consideration the CPU rendering time; to optimize the scene we introduced the Distance Culling in the Planar Reflections, which allows not to render elements that are at a certain distance. All Culling processes are managed and thus calculated by the CPU (in Unreal there are mainly 4 types of Culling).

Now, let’s explain how we optimized the Planar Reflections: we only worked on the settings associated to the single Planar Reflection element. Look below to see which value we changed.

The biggest impact is given by three elements:

  • remove the tick from Capture Every Frame. In this way the calculation of the reflection doesn’t happen in every frame but only when the user moves or when the objects in the reflected image are moved.
  • decrease the Screen Percentage value from 50 to 10. In this way you render with a resolution which is 10% of the frame resolution and not 50% (default).
  • set the Max View Distance Override value to 800. It calculates in the reflection only the elements within the distance given by the value; in this case 800 (cm), which means that elements further than 8 meters won’t be considered in the calculation.

In the image on the right, you can see that we removed most of the ticks even when those elements weren’t in the scene. In fact, when they’re removed, elements like Dynamic Shadows created by trees outside the scene can give benefits.

Below you can confront the difference in terms of quality of reflections on the surface of the kitchen island: before and after the optimization.

Unoptimized
Optimized Planar Reflection

The kind of optimization applied in this case isn’t necessarily the best or the only available.
The process used may vary according to the goal you want to achieve: for instance if you are looking for the maximum quality or the best game fluidity, the approach may vary.

For example if your goal is to get the highest quality (always with an eye on performances), instead of changing the Planar Reflections (regardless where you are in the scene), you can create a Blueprint which allows you to overwrite the settings. However as hard and long as the use of Blueprint can be, it is useful when we have to scale our project to control the performance according to the hardware on which the game will be used.

Another option would be to hide the Planar Reflections thanks to the trigger volumes or the traces (so only using the Unreal default reflections), always in accordance with the distance between us and the Planar Reflection object.

In case pur performances don’t change, although we optimized the Planar Reflections, we can completely remove the Planar Reflections and only use the Sphere Captures. In our test this solution gave a further improvement of about 4 ms in the GPU value. However this damages the quality of the image as we can see in the following image.

Sphere Captures Reflections

Unfortunately in this tutorial we can’t deal with all these different solutions. So, if you want to discover more, join us in our next Unreal Engine Masterclass where we’ll go into deep into optimization and more topics.

To the next tutorial!

Enrico

If you want to find our all tricks on Unreal Engine, join us in our next course.

Share this