Search Unity

How to apply a custom forward renderer masking to UI elements

Discussion in 'Universal Render Pipeline' started by Deleted User, Sep 13, 2021.

  1. Deleted User

    Deleted User

    Guest

    Hello would anyone be able to explain to me how to make my custom forward renderer features apply to UI elements? I saw and recorded this issue in my game yesterday:


    If you do not prefer a video format: Here is a picture of what my "Only Visible in light" feature definition looks like. This feature is being applied perfectly to non-UI elements but the UI elements are not following it's rules. They always render no matter what. It is clear to me that UI elements need separate masking but I am not sure how to communicate the UI mask instructions from my custom forward renderer.
     
  2. Deleted User

    Deleted User

    Guest

    I understand that the Custom Forward Renderer writes to a stencil buffer. But is that buffer global, meaning could we access it from shader code? Is it's id the thing we are setting with the 'Value' slider?
     
  3. Jonas-Mortensen

    Jonas-Mortensen

    Unity Technologies

    Joined:
    Jan 3, 2020
    Posts:
    110
    Not an exact solution but have you tried using 3D Object -> Text - TextMeshPro for the text elements?
    With it you might be able to avoid having to use the canvas?
    I think for rendering purposes all UI elements under a canvas are considered the same layer as the canvas itself. I guess you could test that by changing the layer of the canvas and see if that updates the behavior of the children UI elements
     
    Deleted User likes this.
  4. Deleted User

    Deleted User

    Guest

    Hello my friend, Jonas! That was exactly the solution. So in summary, it would seem that the layer of a UI element will not override its canvas layer (at least pertaining to rendering as you stated). It would be great to clarify that in the drop down selection of UI elements in the editor as this is not something I would have guessed on my own. I am very grateful for your aid. Thank you. @Jonas-Mortensen
     
    Jonas-Mortensen likes this.