Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Clear coat behaving strangely with raytraced reflections

Discussion in 'HDRP Ray Tracing' started by LyCheSis, Feb 3, 2021.

  1. LyCheSis

    LyCheSis

    Joined:
    May 3, 2012
    Posts:
    4
    It's really cool being able to experiment with DXR features in Unity, but I've been having issues getting metallic materials with clear coat to work and I'm out of ideas on how to solve this.

    I'm using Unity 2020.2.2f1, HDRP 10.2.2, although I've also tried Unity 2021.1.0b4 and older Unity versions with the same results.

    I created some screenshots to show the issue:

    Normal: Without raytracing enabled, if I bake a reflection probe everything looks good and all materials behave as expected.

    DXR: With raytraced reflections enabled normal materials [4] and [5] look good and show nice raytraced reflections.

    If I enable clear coat then the metallic part of the material seems to stop to ray trace reflections, visible in [1], [2] and [3].

    The clear coat receives ray traced reflections, but for some reason the HDRP Lit shader has these blurred (with rough material [3] being more blurred, but smooth material [2] is also blurred, which is plainly wrong.

    I tried creating a Shader Graph shader with StackLit master node and enabled clear coat [1] and that works with sharp clear coat reflections on a rough metallic surface, but because the rough metallic surface isn't receiving ray traced reflections it only reflects the skybox.

    If I try to fake the metallic reflections by using a reflection probe then the metallic reflections will look good for the HDRP Lit shader, but the clear coat will also receive the reflection probe, which then is sharp (which I want) but has an offset (which I don't want).

    The Shader Graph StackLit shader on the other hand will not be influenced by the reflection probe, so that the metallic part will only receive specular reflections from the light source and no blurred reflections at all.

    All of this actually looks like there's a system to it, but it's currently not functioning in a way that I'd say I could use clear coated material with raytraced reflections.

    UnityHDRP-Normal-Probe.jpg UnityHDRP-DXR.jpg UnityHDRP-DXR-Probe.jpg
     
  2. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    766
    Hello, thanks for the detailed feedback. It is much appreciated.

    The stacklit behavior has just been fixed to match what is happening with the lit with a clear coat mask value > 0.

    To clarify here's the logic behind what is happening:
    We will also update documentation to have that explanation somewhere official.
     
    Last edited: Mar 16, 2021
    m0nsky likes this.
  3. m0nsky

    m0nsky

    Joined:
    Dec 9, 2015
    Posts:
    257
    @auzaiffe have you been able to verify this against any existing stacklit clearcoat materials? I'm getting some strange results after your PR.

    Before #3872


    After #3872


    I've tried various stacklit clearcoat materials and I'm getting the same results so I have reverted the PR locally for now.
     
    sendspace likes this.
  4. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    486
    I guess you need reflection probe now because base layer of metal reflecting sky now
     
  5. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    766
    Indeed, before this PR, you could only see the specular contribution on the base layer with stacklit shader with clear coat ON. Now, it should follow the proper reflection hierarchy which is probe then sky, since SSR (or RTR) are going to be used for the clear coat reflection.

    To be 100% sure there is not issue you can replace your stacklit with a lit with a coat value > 0, they should behave the same way.
     
  6. m0nsky

    m0nsky

    Joined:
    Dec 9, 2015
    Posts:
    257
    Can an option be introduced to use SSR/RTR for both layers (base and clear coat) in StackLit? I think having to setup and bake reflection probes in a realtime ray tracing project is a step backwards (in both quality and workflow) and defeats the purpose.
     
    keeponshading likes this.
  7. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    766
    Even in a raytracing workflow, it does absolutely makes sense to have a fallback mechanism like probes.
    There are scenarios where your object's material smoothness can be lower than the min smoothness threshold for RTR, even for RTGI you would need a fallback for addtional bounces of indirect lights...etc.

    As for your question, currently, there's only one layer of SSR/RTR per object material, we only sample one roughness. While it would be possible to implement multiple layers, it would complexify and I'm not sure it would be justified there.
     
  8. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    It does, but not for the clearcoat shader if you specifically want realtime raytraced reflections on it (not talking about SSR fallback now which requires the probe fallback regardless).

    Only use case where I could see the probe combined approach work nicely with raytracing setup if it's some showcase room / car configurator thing but if you want to render accurate reflections on car paint for vehicle that actually moves in the scene, relying on probes for one layer of the paint is just no go. HDRP doesn't have fast enough realtime reflection probes and manually placing bunch prebaked ones isn't going to work properly either.
     
    keeponshading likes this.
  9. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    766
    I understand why it could be useful and it has already been under consideration in the past.
    The main issue with implementing it would be performance, SSR/RTR are already costly and we can't really afford doubling that cost. Also, we would need to rely not on one but 2 normal buffer which has non negligeable memory footprint.
    The few cases (mostly some industries verticals) where it would be needed won't make it a priority.
    However, it's not totally out of the question and maybe we'll re-consider it someday.

    Also, if what you're looking for is quality and don't really care about the "cost" of rendering, Stacklit shader will soon be supported by the Path Tracer.
     
    keeponshading likes this.
  10. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hello. Carpaint has clearcoat. Cars move.) This would help to get best in class for all these use cases.
    Without i see no possibility to render correct carpaint en move.
    Would be nice if you give the possibility that the user can decide to use it or not.

    For following use case i could spend lots of performance to have an workable/realistic carpaint en move because raytraced reflections are the most important like you see here for car to car and environment to car reflections.



    So there are at least the complete industrial automotive brach and car race gaming.
     
    Last edited: Jun 4, 2021