Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Metallic material issue with ray tracing

Discussion in 'High Definition Render Pipeline' started by albertoforgione, Sep 13, 2023.

  1. albertoforgione

    albertoforgione

    Joined:
    Jun 6, 2019
    Posts:
    14
    Hey there,

    I'm having some issues with metallic materials behaving oddly in interiors and shadowy areas in general with SSGI (Screen Space Global Illumination).
    l'll leave a screenshot here with an example pool table half placed directly under the sun and half in the shadow.

    This is with SSGI/RayMarching:



    This is with SSGI/RayTracing:



    As you can see, the table corners completely lose their metallic feel and become "plasticky" under the shadow.
    I've tweaked all SSGI settings (including bounce and sample count) but to no avail.
    If I enable the SSGI fallback settings, there are some changes in the overall illumination but nothing that seems to properly affect the metalness. Despite not fixing the issue, the fallback settings having an impact gets me thinking that perhaps SSGI fall backs to non-RTX settings which might explain the odd behaviour. The other RTX effects I have on don't seem to respond to fallback settings (e.g. ray traced reflections).

    Also, this is with 'Metallic Indirect Fallback' ticked on under the HDRP/Global Settings.
    If I tick it off, the metallic materials preserve their aspect but turn completely dark, which is obviously no good either.

    Any help would be appreciated.
    Thanks in advance.
     
  2. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    308
    I think that Metallic Indirect Fallback is meant to be switched on in the frame settings for rendering real-time reflection probes, not in the frame settings for the camera.... because it will make the metal look like diffuse, which is the problem you are describing.

    With the setting off, I'm not sure why the metals appear so dark, even with a high albedo value assigned. I noticed it too, especially when the metallic object is not in any direct light. It seems a little wrong compared to real world objects. I mean, for reference, right now I can see a silver metallic object in my room, totally in the shadow (no direct light)... it appears very bright and very reflective.
     
  3. albertoforgione

    albertoforgione

    Joined:
    Jun 6, 2019
    Posts:
    14
    Unfortunately, only Frame Settings/Camera seems to actually respond, Frame Settings/Realtime Reflections is completely unresponsive, regardless of which entry I tick/untick.

    Any ideas as to why this might be happening?
     
  4. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    308
    Frame Settings/Realtime Reflections is what will be rendered into the faces of reflection probes... so you won't generally see a difference unless you have a case like this:

    Question - HDRP metallic materials are all black in reflection using reflection probes - Unity Forum
     
  5. albertoforgione

    albertoforgione

    Joined:
    Jun 6, 2019
    Posts:
    14
    I’m not using any reflection probes, just ray traced reflections, so the only option that makes a difference is the Camera one.

    In general I’m a bit puzzled as to why this only happens in shadowy areas. According to the Unity documentation the metallic materials aren’t receiving enough light bounces and I don’t understand why.
     
  6. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    749
    I'm a bit puzzled by this result as well, this does not really make sense.
    What version of the engine are you using ?
     
  7. albertoforgione

    albertoforgione

    Joined:
    Jun 6, 2019
    Posts:
    14
    I'm using 2023.1.7 but I've had it happen with other versions too.

    Toning down the Indirect Diffuse Lighting Multiplier in the Indirect Lighting Controller volume override mitigates the issue and makes the 'metalness' come out a bit more, however this also enhances the shadows darkness as a flipside.
    While the override has the ability to specify light layers, it's kinda tricky with metallic materials as materials can't sit on separate layers, or even if they could, parts of the same materials have different metallic values depending on the metallic map in the mask map.
    Disabling the Metallic Indirect Fallback setting removes the plasticky effect, however the metallic part turns out completely black.

    Ideally, it would be nice to either change the colour/intensity of the Metallic Indirect Fallback setting or have the Indirect Diffuse Lighting Multiplier only affect metallic parts as an option.
     
  8. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    749
    I can't repro on my side, but I agree it seems fishy.
    Best way to move forward would be to create a bug report with a simple repro to make sure we can actually ecounter the problem on our side!

    Thanks in advance.
     
  9. albertoforgione

    albertoforgione

    Joined:
    Jun 6, 2019
    Posts:
    14
    I've just submitted the bug report and attached the repo project as necessary.
    CASE IN-55436

    Please note that that other user experienced the same issue, suggesting that there is something off in the Rendering Pipeline as it stands, so I guess it would be ideal to have this looked into asap.

    Thanks in advance for your time.
     
    chap-unity likes this.
  10. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    749
    Thank you!
     
  11. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    749
    I had a look out of curiosity and you are missing "sky reflection" in your HDRP default settings, which means that given you don't have a reflection probe either in your scene, there's no specular information for your mettalic parts to fallback on. Since you have mettalic indirect fallback on, the reflection are not black but fallback as a diffuse material with the set base color. So to me, it sounds completely expected.

    Can you try to check that back up and put a reflection probe (to at least have some occlusion from your shell) and see if everything is back in order?

    upload_2023-9-21_14-16-4.png
     
  12. albertoforgione

    albertoforgione

    Joined:
    Jun 6, 2019
    Posts:
    14
    Unfortunately I've already tried this several times but to no avail.





    Yes, this makes the metallic parts a bight brighter, however it's still off altogether. As a matter of fact, the metallic corners under the shadow got even brighter, as opposed to darker and lost some of the fine details from the smoothness map.
    Also, I had to discard Sky Reflection as it would lead to incorrect looking materials elsewhere.

    In the repo project I submitted I forgot to include Ray Traced Reflections, but I'm using those to get realtime specularity.
     
    Last edited: Sep 22, 2023
  13. albertoforgione

    albertoforgione

    Joined:
    Jun 6, 2019
    Posts:
    14
    @chap-unity has anyone been able to investigate on this at all? Thanks.
     
  14. m0nsky

    m0nsky

    Joined:
    Dec 9, 2015
    Posts:
    257
    @albertoforgione there is no issue, I'll try to explain what's going on in your case.

    Your material is full metallic & smooth, which means there is no diffuse, it is a pure mirror reflection.

    Lighting inside ray traced reflections is not ray traced (doing this is very heavy and results in complex sampling/denoising scenarios). The only way to get accurate lighting inside ray traced reflections, is to bake your lighting & reflection probes.

    If you decide not to do this, there will be no accurate lighting available inside the reflections, so it will fall back to the sky, which will obviously be too bright in an area where the sky should not be visible. (like you observed in your previous post)

    If you then also disable the sky, you will have a full specular surface with all specular contribution disabled, which will fall back to pure diffuse. (like you observed in your opening post)

    All of this is also mentioned in the realtime ray tracing troubleshooting guide
     
    Last edited: Oct 11, 2023
    chap-unity likes this.
  15. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    749
    Thanks @m0nsky for the longer explanation, I agree that there's no issue.
    It's just the complex ray tracing fallback hierarchy that's not trivial to understand.
     
  16. albertoforgione

    albertoforgione

    Joined:
    Jun 6, 2019
    Posts:
    14
    Ok that clarifies things a bit.
    Although in my case, my material is not a pure mirror reflection. It is fully metallic but only partially smooth.

    Sounds like my best bet would be to create reflection probes and set them as the last bounce.
    Can I get away with realtime reflection probes?
    In the realtime ray tracing troubleshooting guide it mentions this as a possibility.
     
  17. m0nsky

    m0nsky

    Joined:
    Dec 9, 2015
    Posts:
    257
    Yes, that will work. Also, if you use "Time Slicing" option on your real time reflection probe, the performance impact will be reduced.

     
    chap-unity likes this.
  18. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,482
    Metallic objects reflect the environment and are very dependent on the environment. You have the pool table surrounded by grey walls and nothing else, of course it looks weird.