Search Unity

Question World Space UI and "Before Refraction" - No good solution?

Discussion in 'High Definition Render Pipeline' started by dgoyette, Sep 28, 2021.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    Hopefully I'm just missing something here. I'm trying to get some world-space UI elements to look correct when they are placed either in front of or behind a refractive material. What I'm finding is that I can only get it to look correct either in front or behind the refractive material, but not both. It seems like this is something that should be handled based on depth / z-order, but as far as I can tell, it's a single catch-all switch.

    For example, I have a floating image on a world space canvas. Here is it in front of some refractive glass:

    upload_2021-9-28_0-25-55.png

    The image is getting cut in half because the button material's Rendering Pass is "Default". I can "fix" this by changing the rendering pass to "Before Refraction":

    upload_2021-9-28_0-24-12.png

    But now the portion of the image in front of the refractive material is getting refracted.

    I can continue to tweak things on the material, by changing things like Depth Write and Depth Test, but the image never looks correct. It's either refracted, or it causes all of the scene behind the image not to be refracted.

    And if I don't set the image to Before Refraction, then it won't be refracted when it's actually behind some refractive material, which looks noticeably weird, since everything else is refracted.

    Is there some combination I'm missing here, where world-space canvas elements can appear correctly in front or or behind refractive materials? I'm on HDRP 7.7.1, so perhaps this is something improved in a later version? Or is this a no-win situation?