Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Refract fullscreen atmosphere effect while underwater?

Discussion in 'Image Effects' started by RobronicGames, Feb 11, 2023.

  1. RobronicGames

    RobronicGames

    Joined:
    Nov 15, 2018
    Posts:
    33
    Hello,

    I have a planet with a custom fullscreen atmosphere pass and I'm adding some simple water to it with a custom shader:
    upload_2023-2-11_11-58-38.png

    Currently, everything works fine until I go underwater:

    upload_2023-2-11_12-2-45.png

    The water is refracting everything correctly, but the atmosphere effect obviously still uses an unrefracted depth texture, causing gaps (dark blue) where the unrefracted terrain would be. My question is, how can I have the atmosphere effect use a refracted depth texture?

    I discovered this info on the HDRP Custom Passes page that describes the ability to have a custom depth buffer and using that in sequential fullscreen effects:

    upload_2023-2-11_12-10-6.png

    But I'm not sure this is viable. I'd have to simulate the refraction in a separate fullscreen pass, before the atmosphere pass, at arbitrary water surface points, sampling the exact normals the water itself is currently sampling at that same point, project that onto the current depth buffer for that pixel and writing it to the custom depth buffer?

    I don't know at all if I'm on the right track with this, I hope someone here can help me find my way!