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

Question Render 3D objects on top of the screen with 2 cameras.

Discussion in 'High Definition Render Pipeline' started by Sergio_SQ, Jun 24, 2020.

  1. Sergio_SQ

    Sergio_SQ

    Joined:
    Jun 11, 2020
    Posts:
    7
    I'm migrating my project to HDRP and I found some features that are not working anymore.

    I want to render a rotating coin on top of the screen as UI but that is a 3D model.
    I'm using 2 cameras. 1 for the whole game and another one for this overlay object.
    The top camera is somewhere else in orthographic and set as Background Type: None. Both render different layers.
    The coin renders fine, but all the post process effects are cleared as you see in the images when I turn on the camera.

    I tried using a render to texture but alpha is not been included in the texture.

    How is this suppose to be done?

    upload_2020-6-24_13-28-20.png

    upload_2020-6-24_13-28-40.png
     
  2. tuinal

    tuinal

    Joined:
    Dec 14, 2012
    Posts:
    17
    Use a custom vertex shader on the coin that doesn't apply the viewing transformation.

    https://learn.unity.com/tutorial/shadergraph-vertex-position#5d8ce3aaedbc2a001fe6d034

    This will let you keep to a single camera which is much better for performance.

    You could of course alternatively just stick the coin infront of the camera as a child.

    Either way the annoying bit will be making sure it scales correctly if it's meant to work with other UI elements.
     
  3. Sergio_SQ

    Sergio_SQ

    Joined:
    Jun 11, 2020
    Posts:
    7
    Thanks fot the answer.

    Don't think that would work. My coin rotates and it's lit in realtime. It is a loading icon element.
    Sticking it to the camera it's an option but, It woud deform fecause of the persepective. I could even place the object very far away from the camera to avoid the deformation and scale it to compensate the size, but I don't like the idea of having stuff like this as child of my main camera.
     
  4. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,010
    This is kind of a hack since i think that your solution with two cameras should work fine, but I dont use HDRP so I don''t know.

    But you could try to render your coin to texture and use this texture in UI.
     
  5. Sergio_SQ

    Sergio_SQ

    Joined:
    Jun 11, 2020
    Posts:
    7
    I could use render texture if I had a way to get the depth alpha channel. Because render texture do not save the alpha channel anymore.