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. Dismiss Notice

Question How to remove head for the player camera, but keeping it in reflections

Discussion in 'VR' started by Sheynes, Aug 19, 2021.

  1. Sheynes

    Sheynes

    Joined:
    Mar 27, 2017
    Posts:
    66
    Hello,
    So I have this IK, with the camera inside my head. I can see my head inside, the hairs clipping around too, and I do not want to change the camera clipping plane value because I need it as close as 0 as possible to get a better immersion when the player inspect object from closeup.

    So I am looking for ways to keep my character head meshs, to remove it from the player camera view so the player camera doesn't clip with it's own head. However i'd like the player shadows to still have a head and the player mirrors reflections too.

    How would one go to solve this problem ?
     
    WidmerNoel likes this.
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,842
    You can use the camera culling mask to prevent the VR camera from rendering the head, while using a different mask values for shadows and the reflection camera, so that it shows up for them.
     
  3. Sheynes

    Sheynes

    Joined:
    Mar 27, 2017
    Posts:
    66
    How would you proceed to apply a mask for the shadow ? Since the shadow projected must be seen by the player camera that hide his head ? I'm using HDRP btw I dunno if the process would be different :D
     
    Arcane_Entity likes this.
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,842
    Just don't set a cullingMask on the light, so that it applies to everything including the head.
     
    Sheynes likes this.
  5. Sheynes

    Sheynes

    Joined:
    Mar 27, 2017
    Posts:
    66
    Awesome I guess it's the way to go !
    Thank you
     
  6. Sheynes

    Sheynes

    Joined:
    Mar 27, 2017
    Posts:
    66
    Hmm, although I just realized that actually my whole player is the same mesh. Perhaps I could do an approach like scaling the head to zero on local or something. Or is this possible to apply a culling mask on bones and meshs linked to them ?
     
  7. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,842
    Ah, if it's all one mesh than this is much harder. You can't mask by bones. You can scale the head bone to 0, but then it won't be casting shadows or showing in reflections.

    I'm not sure there is any solution here that doesn't involve severing the head from the body.
     
  8. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    736
    You can increase the camera nearClipPlane, this is the easiest solution I found so far, but has other disadvantages, if you get near to other objects.