Sunday, August 24, 2014

[Unreal Engine 4] Improving Screen Space Reflections

If you ever felt the need to adjust or improve the built-in screen space reflections of UE4 take a look at the ScreenSpaceReflections.usf shader file.
It's located in this directory: \Unreal Engine\4.x\Engine\Shaders\

In the SSR shader file search for this part of the code. The line number varies a bit with each engine version, but it should be somewhere around 340-350.
#if SSR_QUALITY == 1
const int NumSteps = 8;
const int NumRays = 1;
#elif SSR_QUALITY == 2
const int NumSteps = 16;
const int NumRays = 1;
#elif SSR_QUALITY == 3
const int NumSteps = 8;
const int NumRays = 4;
#else // SSR_QUALITY == 4
const int NumSteps = 12;
const int NumRays = 12;
#endif
There are 3 quality levels with 2 parameters which define the quality of reflections.

NumSteps - Number of steps. This defines the accuracy of reflections and causes a reasonable performance impact.
For any value above 32 you will hardly notice a difference
NumRays - Number of rays. Using more rays takes away the noise of reflections but is rather expensive.

The default settings are a bit strange since the number of steps drops from 16 back to 8 at quality level 3. My recommendation would be to set NumSteps to 16 for high quality. This comes at a little performance impact. You might also lower NumRays by 1 at the same time to gain back the lost FPS.

Here's a set of screenshots to demonstrate various value combinations as well as their impact on performance.

NumSteps=8 / NumRays=1

NumSteps=16 / NumRays=1

NumSteps=16 / NumRays=2

NumSteps=8 / NumRays=4

NumSteps=16 / NumRays=4

NumSteps=16 / NumRays=8

NumSteps=32 / NumRays=4

NumSteps=32 / NumRays=8

NumSteps=32 / NumRays=32

2 comments:

  1. No, this is not possible. You can only change the SSR quality level via console command or in the post process volume settings, so that's 4 presets to test per run.

    ReplyDelete
  2. I just want to say thank you!

    ReplyDelete