Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Resolved In-Game Interactable Phone/Tablet in HDRP

Discussion in 'High Definition Render Pipeline' started by xX0Survivor0Xx, Aug 24, 2021.

  1. xX0Survivor0Xx

    xX0Survivor0Xx

    Joined:
    Apr 27, 2013
    Posts:
    6
    Hello, I have a problem that I have been trying to solve for almost 2 months (For real). I'm trying to make an in-game interactable phone/tablet. The only two ways for doing this that I found are: using World Space canvas or Screen Space - Camera canvas with render texture. The problems are: when using World Space canvas, it only works perfectly when you are around position (0,0,0). The jitter / distortion is getting worse when you are moving away from the (0,0,0) position. Here I made a video capturing this behaviour (sorry for the low fps video, the problems are visible anyway):

    Here i used the sample scene from Unity HDRP template (2021.1.17f1). The only thing that I added is the World Space canvas and I disabled the Motion Blur.

    The other way that I tried was using Screen Space - Camera canvas, a camera with render texture and a custom Graphic Raycaster script for canvas input. The problem here is that the performance is reaaaaally bad (from ~50-60 fps to 25-30 fps). It seems that the second camera doesn't know how to render only the layer with UI.
    Is it any work around for any of these? (Especially the World Space one)
    Thanks!
     
  2. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    715
    Hey, thanks for bringing this to our attention.
    I don't know much about how canvas is implemented but it looks like something that's not expected indeed.
    It could be some precisions issues related to the position of the canvas the further you are from the origin.

    In any case, it seems like you have a pretty good repro, could you report an issue with your project and drop the case number here for us to investigate ?

    Thanks.
     
  3. xX0Survivor0Xx

    xX0Survivor0Xx

    Joined:
    Apr 27, 2013
    Posts:
    6
    Hi, here is the number:
    1360425
     
    chap-unity likes this.
  4. antoinel_unity

    antoinel_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    237
    Hello, I looked at the issue and it's indeed a precision issue like chap said.

    The problem lies in both the canvas vertex position generation on CPU and in shaders so it's not possible to fix it on HDRP side (even if you replace the UI shader with an HDRP unlit shader that supports camera relative rendering it won't work because the UI canvas just doesn't support being far away from the origin).

    The only workaround, for now, is to scale up the UI so you don't notice the bug anymore, I know it's not practical but I don't see another way around it.

    I've forwarded the issue to the UI team but I don't know how hard it is to fix.
     
    Ruchir and chap-unity like this.
  5. xX0Survivor0Xx

    xX0Survivor0Xx

    Joined:
    Apr 27, 2013
    Posts:
    6
    Hello, thanks for response, I solved the problem placing the canvas with scale (1,1,1) far from player and using a custom UI shader that renders on top of everything. I hope that will be an easier workaround in the future. Thanks!

     
    chap-unity and antoinel_unity like this.
  6. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    715
    Quick update on this one;
    The issue has been closed as "Won't fix". The problem is that when in World Space, the canvas vertices are first transformed to world space and then to camera space depending on the canvas settings. This round trip coordinates conversion are generating some precisions issue the higher the value.

    For now, if you have to stay in World Space Canvas, there's no better solution.