Search Unity

Bug Screen Space Reflections close to unusable in HDRP

Discussion in 'High Definition Render Pipeline' started by dmchaderer, Jun 18, 2020.

  1. dmchaderer

    dmchaderer

    Joined:
    Nov 13, 2019
    Posts:
    23
    Hi,

    I did enable SSR to add some extra detail to my reflections. Sadly, the results are pretty much unusable.
    If you use the default settings, you hardly see any reflections. And if you up the Ray Steps like crazy (512) you finally see some, but they have weird streaks that are flickering.

    ssr_default.PNG
    ssr_maxSamples.PNG

    Even areas where there are pixels on screen that could be reflected get no reflection like for example the character. I don’t know how Unreal for example went about the missing blackface problem but somehow, they managed to get reasonable results and conceal the shortcomings of this being a screen space effect.

    It would be great if this effect could be improved.

    Best Regards
    Dominik


    I tested this on Unity 2019.4.0 with HDRP 7.3.1
    [Edit] got the same results on 2020.1b12 with HDRP 8.1.0
     
    Last edited: Jun 19, 2020
  2. mahenkumar

    mahenkumar

    Joined:
    Oct 8, 2014
    Posts:
    20
    I have the sample problem since Unity 2019. Even the built in render provides way much better SSR. I don't know why they don't fix it ?
     
  3. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi, we are aware of the issue and are investing on fixing the quality issue.
     
    Camarent and olavrv like this.
  4. ArnoldCarterWong

    ArnoldCarterWong

    Joined:
    Sep 26, 2017
    Posts:
    31
    Also the crazy flickering problem when the thickness is greater than 0.001, apart from the SSR issues the HDRP is great.
     
  5. dmchaderer

    dmchaderer

    Joined:
    Nov 13, 2019
    Posts:
    23
    Thank you so much! I can't wait. :)
     
  6. Camarent

    Camarent

    Joined:
    Feb 19, 2014
    Posts:
    168
    I also met this problem with SSR and I am not sure what to do. One way is to avoid flat reflected surfaces. Another one - using planar reflections.

    I also tried to use stohastic ssr like this in builtin - https://github.com/simeonradivoev/ComputeStochasticReflections
    I think it can be ported for hdrp but this will be compute-intensive effect.

    Current Unity effect will be okay if they will add blur and taa filters for it.
     
  7. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    They are working on it. WIP branch here https://github.com/Unity-Technologies/Graphics/tree/HDRP/ssr_improvement. But don't try it yet, the branch doesn't work yet with the latest commits.

    I've tested this on earlier commits (both before the initial temporal denoising and with the first pass for it) and it looks very promising, it's just too noisy to be used with these but looking at the later work it looks like they are solving the denoising now, we just need to be patient :)

    Noise aside, the sampling results are quite similar to what we currently get with DXR reflections on rougher surfaces when you don't enable denoising for it. Their first denoising pass still left the image too alive but this is WIP still so can't really make any real conclusions on that part.
     
    Last edited: Sep 2, 2020
    fuzzy3d and Lex4art like this.
  8. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    to give some preview, here's before and after how it looked without any denoising:

    current SSR solution (wall material has metallic of 1 and smoothness of 0.85):


    SSR improvement without any denoising:


    DXR reflection without denoising:
     
    ktitov-nekki, DrSeltsam and Lex4art like this.
  9. Passeridae

    Passeridae

    Joined:
    Jun 16, 2019
    Posts:
    395
    Finally! I hope they'll include this in HDRP 10 at some point in the near future.
     
  10. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    The above samples use a bump map or is just a bug that make the distortion ?
     
  11. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    No distortion here. It looks noisy to fake rough reflections, and needs a denoising pass to be better.
     
  12. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    I see, thanks
     
  13. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
  14. valarnur

    valarnur

    Joined:
    Apr 7, 2019
    Posts:
    440
  15. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Probably some future 10.x release but that's just my guess. It does work on 2020.2 on my testing.

    That being said, while the still images can look pretty nice, there's still some serious issues with denoising due to the requirement of using temporal accumulation to get rid of the noise (it takes a long time to converge to a pleasantly blurred result):
    https://www.dropbox.com/s/i1j77yiip6g3h08/new_ssr.mp4?dl=0
     
    fuzzy3d, Camarent and Lex4art like this.
  16. dmchaderer

    dmchaderer

    Joined:
    Nov 13, 2019
    Posts:
    23
    Thank you 0lento,

    that is looking way better already! I will try out the update branch with the 2020.2 very soon.
    Do you also have ideas on concealing the backface issue?

    Best
    Dominik
     
  17. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    SSR improvement just got merged to master. I'm still quite concerned how slow it is to converge on anything but still shots (tested on latest master branch with 2021.1.0a2):

    https://www.dropbox.com/s/ngfgc3s8hcc3m9b/newSSR.mp4

    I don't think this is going to work for any fast paced game but more for like slowly moving visualizations.
     
  18. dmchaderer

    dmchaderer

    Joined:
    Nov 13, 2019
    Posts:
    23
    Hi,

    I finally got around to test out the new SSR with the temporal accumulation. And it is a huge improvement on the last version! Big thanks for that.

    I noticed though, that due to the speed rejection, you implemented there, in dark scenes with emissive materials in it you get some nasty firefly artifacts when moving the camera. These last until the accumulation kicks in again.

    I tried working around this by displacing the history-buffer sample by the motion vectors to keep the reflections in place and lowering the speed rejection blend. This works for the most part but also introduces smears if the scene gets too contrasty.

    Do you have any thoughts on how to deal with the firefly-issue, or some input on my hack? (see the code below)

    How are your efforts with the SSR going? Any plans for further updates?

    Cheers
    Dominik


    Code (CSharp):
    1. [numthreads(8, 8, 1)]
    2. void ScreenSpaceReflectionsAccumulate(uint3 dispatchThreadId : SV_DispatchThreadID)
    3. {
    4.     UNITY_XR_ASSIGN_VIEW_INDEX(dispatchThreadId.z);
    5.     uint2 positionSS = dispatchThreadId.xy;
    6.  
    7.     float3 N;
    8.     float perceptualRoughness0;
    9.     GetNormalAndPerceptualRoughness(positionSS, N, perceptualRoughness0);
    10.  
    11.     // Compute the actual roughness
    12.     float roughness = PerceptualRoughnessToRoughness(perceptualRoughness0);
    13.     roughness = clamp(roughness, MIN_GGX_ROUGHNESS, MAX_GGX_ROUGHNESS);
    14.  
    15.     float4 data0 = _SSRAccumTexture[COORD_TEXTURE2D_X(int2(positionSS))];
    16.  
    17.     float2 hitPositionNDC = LOAD_TEXTURE2D_X(_SsrHitPointTexture, positionSS).xy;
    18.  
    19.     // Approximate the footprint based on the hit normal
    20.     float2 hitSS = (hitPositionNDC.xy - (0.5 * _ColorPyramidUvScaleAndLimitPrevFrame.zw)) / _ColorPyramidUvScaleAndLimitPrevFrame.zw;
    21.  
    22.     NormalData hitNormalData;
    23.     DecodeFromNormalBuffer(hitSS, hitNormalData);
    24.     float3 hitN = hitNormalData.normalWS;
    25.  
    26.     float4 original = _SSRAccumTexture[COORD_TEXTURE2D_X(positionSS)];
    27.     float4 previous = _SsrAccumPrev[COORD_TEXTURE2D_X(positionSS * _RTHandleScaleHistory.zw / _RTHandleScaleHistory.xy)];
    28.    
    29.     // CUSTOM CODE BEGIN
    30.     // TODO remove other sample if this should work out
    31.     float2 motionVector;
    32.     float2 texcoordNDC = positionSS * _ScreenSize.zw + (0.5 * _ScreenSize.zw);  // tranpose to  normalized screen pos as input
    33.     DecodeMotionVector(SAMPLE_TEXTURE2D_X_LOD(_CameraMotionVectorsTexture, s_linear_clamp_sampler, min(texcoordNDC, 1.0f - 0.5f * _ScreenSize.zw) * _RTHandleScale.xy, 0), motionVector);
    34.  
    35.     float2 motionVectorSS = motionVector / _ScreenSize.zw;
    36.     float2 prevSS = float2(positionSS.x, positionSS.y);
    37.     // sometimes small motion occurs out of nowhere. could be floating point errors. it gives smears and blurry artifatcs. thats why i clamp it here
    38.     if (length(motionVectorSS) < 0.33) {
    39.         motionVectorSS = float2(0, 0);
    40.     }
    41.     prevSS = prevSS - motionVectorSS; // offset motion vector  
    42.  
    43.     previous = _SsrAccumPrev[COORD_TEXTURE2D_X(prevSS * _RTHandleScaleHistory.zw / _RTHandleScaleHistory.xy)];
    44.     // CUSTOM CODE END
    45.    
    46.  
    47.     float2 motionVectorNDC;
    48.     DecodeMotionVector(SAMPLE_TEXTURE2D_X_LOD(_CameraMotionVectorsTexture, s_linear_clamp_sampler, min(hitPositionNDC.xy, 1.0f - 0.5f * _ScreenSize.zw) * _RTHandleScale.xy, 0), motionVectorNDC);
    49.     float speedDst = length(motionVectorNDC);
    50.  
    51.     float2 motionVectorCenterNDC;
    52.     float2 positionNDC = positionSS * _ScreenSize.zw + (0.5 * _ScreenSize.zw);
    53.     DecodeMotionVector(SAMPLE_TEXTURE2D_X_LOD(_CameraMotionVectorsTexture, s_linear_clamp_sampler, min(positionNDC, 1.0f - 0.5f * _ScreenSize.zw) * _RTHandleScale.xy, 0), motionVectorCenterNDC);
    54.     float speedSrc = length(motionVectorCenterNDC);
    55.     //float speed = saturate((speedDst + speedDst) * 128.0f); // 128 is arbitrary
    56.     float speed = saturate((speedDst + speedDst) * 1.5f); // 1.5 is arbitrary // CUSTOM CODE
    57.  
    58.     float coefExpAvg = lerp(_SsrAccumulationAmount, 1.0f, speed);
    59.     float4 result = lerp(previous, original, coefExpAvg);
    60.  
    61.     uint3 intCol = asuint(result.rgb);
    62.     bool  isPosFin = Max3(intCol.r, intCol.g, intCol.b) < 0x7F800000;
    63.  
    64.     result.rgb = isPosFin ? result.rgb : 0;
    65.     result.w = isPosFin ? result.w : 0;
    66.    
    67.     _SsrLightingTextureRW[COORD_TEXTURE2D_X(positionSS)] = result;
    68.     _SSRAccumTexture[COORD_TEXTURE2D_X(positionSS)] = result;
    69. }
     
    chap-unity and rz_0lento like this.
  19. soleron

    soleron

    Joined:
    Apr 21, 2013
    Posts:
    580
    It mostly works fine for me (2020.2 HDRP 10.2.2) but I DO get some peculiar flickering/flaking artifacts. similar to z-fighiting.