Search Unity

Bug? Render Glass through glass in HDRP

Discussion in 'High Definition Render Pipeline' started by Sean__R, Jan 29, 2022.

  1. Sean__R

    Sean__R

    Joined:
    Oct 1, 2014
    Posts:
    106
    Hello, I cannot seem to render glass through glass. Is this a bug?

    I am using an RTX 2080 with Ray Tracing.

    Has anyone figured this out?


    Render Glass through Glass copy.png
     
  2. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,074
    But can you see the cube through the sphere ?
    This looks like the cube writes to depth buffer and is rendered before sphere.
     
  3. Sean__R

    Sean__R

    Joined:
    Oct 1, 2014
    Posts:
    106
    Nope, the cube cannot render through the sphere. How do you change the depth buffer sorting?
     
  4. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    704
    Hey !
    This is not a bug, it's how refraction is supposed to work : a refractive object samples the color buffer to see through, if you have multiple refractive objects on screen the last rendered one will override the previous ones, as they don't get rendered in the "before refraction" buffer.
    If you always know which one is behind, you can change it's material settings to "renderingPass" = "Before refraction", so it can be displayed in refractive objects, but with the caveat that it can do refraction itself.

    IF you want to stack refraction using raytracing, you need to use "Recursive Rendering", see doc page here : https://docs.unity3d.com/Packages/c...1/manual/Ray-Tracing-Recursive-Rendering.html
     
    valarnur and chap-unity like this.
  5. Sean__R

    Sean__R

    Joined:
    Oct 1, 2014
    Posts:
    106
    Hello Remy, this is what I see in Unity 2021.2.8. Can I ask for some more guidance?

    Clear Glass_v01.png Clear Glass_v02.png

    Below I tried "Low Resulution." I changed the property of the clear glass to thin, so you can see the low rez red glass better. Is there a way to get better resolution and show the color of the red glass in the background?
    Clear Glass_v03.png
     
  6. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    766
    Nope, there's no way in HDRP to stack properly multiple layers of refractive transparent without raytracing.

    The only way to be able to see your red refractive glass behind is to make your first sphere non refractive (set the refraction model to None).

    Otherwise, you are indeed either stuck with the low resolution transparent pass, which gives you, surprisingly, low resolution or the before refraction pass but you'll lose the refraction on the red sphere.
     
    Last edited: Feb 4, 2022
    valarnur likes this.
  7. merpheus

    merpheus

    Joined:
    Mar 5, 2013
    Posts:
    202
    Is there a way to add custom refraction pass that can deal with this issue? I presume this also applies to translucent materials, which we need to use.
     
  8. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    704
    Maybe by using custom passes to do some "refraction before refraction". But you will be on you own for doing that.
     
  9. Sean__R

    Sean__R

    Joined:
    Oct 1, 2014
    Posts:
    106
    I was able to get some better rendering and the red sphere looks a little better; is not so pixelated.
    These are the settings I used.
    Maybe this will also help someone else? Clear Platic settings.png