Search Unity

Question VR Refraction without Opaque Texture

Discussion in 'Universal Render Pipeline' started by Incode, Dec 7, 2022.

  1. Incode

    Incode

    Joined:
    Apr 5, 2015
    Posts:
    78
    Is it possible to get URP VR refraction working without using the opaque texture? Seems like trying to use opaque texture on Quest and URP 10.0.6 still has issues when using MSAA.
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,063
    I don't think URP has a proper way of doing this. There is a grab pass URP extension on git, but I think performance of that will be really bad (not tested tho).
    What is the issue you are having? You could make a bug report for it so it can be fixed instead of finding another workaround.

    I have used opaque textures quite a bit for VR as well
     
  3. Incode

    Incode

    Joined:
    Apr 5, 2015
    Posts:
    78
    As far as I can tell, attempting to use the URP opaque texture path with MSAA doesn't work in 10.x versions of URP, and later versions aren't available to us, since we're still using 2020 LTS. Have you used Opaque on Quest in later versions? I believe this is a Quest specific bug from what I've read.
     
  4. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    The "opaque" texture requires doing a blit internally, which has huge performance implications on quest 1/2 hardware. I really recommend that you do NOT even attempt this on quest, as youre going to massively reduce performance.

    The reason has to do with quest's tiled architecture. When you do a blit, the gpu has to resolve the texture from fast memory into slow memory, make a copy of it, and then get back to tiled rendering again afterwards. You will easily eat up 1ms or more (depending on resolution and msaa quality settings) just to bring OpaqueTexture into existence!
     
  5. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,063
    Can confirm. Just having it enabled without using it was a major performance hit
     
  6. Beauque

    Beauque

    Joined:
    Mar 7, 2017
    Posts:
    61
    I am also looking for a solution to this in 2021.3 / URP 12. Have you eventually found an alternative to get refraction working on VR devices?
     
  7. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,063
    Nope, you probably gotta write your own text-based shader or render feature for that
     
  8. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    769
    What kinds of refraction would you like to achieve. I know that an inaccurate way to have "refraction" can be sampling the reflection probe using refracted direction (imagine that the view direction is the ray direction).

    This should be performant on mobile VR devices compared to screen space refraction.
     
    Beauque and DevDunk like this.
  9. Beauque

    Beauque

    Joined:
    Mar 7, 2017
    Posts:
    61
    Is it possible to do it entirely in a written lit shader ? Do you have an idea of the main steps to follow? If get the theory right I should probably be able to write the shader myself.

    It would be multi-purpose: water shader, wet windshield, raindrop impact ripples (using particles), deformed plexiglas etc. For some of these uses, I guess the reflection probe technique could indeed do the trick. For the car's windshield however, I would need to dynamically get what's behind it.
     
    Last edited: Mar 29, 2023
  10. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    769
    Do you mean the opaque texture still cannot be copied correctly in latest URP 12 when enabling MSAA on VR devices?

    If that's a VR device (GPU driver) issue and you're not going to give up, I'd suggest replacing MSAA with some other anti-aliasing.
     
  11. Beauque

    Beauque

    Joined:
    Mar 7, 2017
    Posts:
    61
    Indeed, it creates a variety of bugs like making the UI invisible, sometimes it just creates some black outline between Renderers and the skybox, and sometimes it just works. The behavior varies accross projects and VR devices and seems quite unpredictable. Not to mention the impact on performances (although in my experience it doesn't look as bad as people usually say here on the forums).

    The thing is, MSAA is useful for other features in mobile VR like Alpha to Coverage and I don't really want to give up on that.
     
    Last edited: Mar 30, 2023
    wwWwwwW1 likes this.
  12. quadro5567

    quadro5567

    Joined:
    Feb 23, 2022
    Posts:
    4
    this bug was first introduce when 2020LTS firs release, cant believe it still not resolved yet
     
  13. vandermky474

    vandermky474

    Joined:
    Feb 28, 2021
    Posts:
    10
    i was wondering for months why my ui was invisible in vr found out a few days ago but that is very anoying that i have to turn it off because i just got a great glass and refraction shader and it looks horrible in vr because of opaque texture. i actually did not notice a frame drop though wich is wierd so i might just turn off MSAA. hope this gets fixed soon.
     
  14. quadro5567

    quadro5567

    Joined:
    Feb 23, 2022
    Posts:
    4
    if you in unity 2021 there's fix actually, you just need to forced the depth priming mode, or you can just choose vulkan graphic API, but the perfomance is garbage, i never get more than 40 fps using vulkan in my scene for some reason upload_2023-9-4_5-36-16.png
     
  15. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,063
    Instead of after opaque maybe use force prepass?

    On the latest version vulkan should be fine for VR