Search Unity

Bug Odd Shadow Issue

Discussion in 'High Definition Render Pipeline' started by mike11986, Sep 5, 2022.

  1. mike11986

    mike11986

    Joined:
    Jul 23, 2018
    Posts:
    24
    I'm having an odd issue where shadows are getting cut off as I walk away from a light, yet another object isn't getting cut off. The following video will help demonstrate:


    Part of the head loses its shadow, yet the full hat (a separate mesh) keeps its shadow. After turning around, something similar happens with the eyes (also a separate mesh). I'm using a point light, and I don't think I have any global illumination going because I don't know how yet. Any idea why this is happening? It might be a bug. I've looked at shadow settings in the HDRP as well as the near plane on the light, but nothing seems to change it. I noticed that if the near plane is set further, more shadow gets cut off, but the 0.01 minimum near plane doesn't help. The light is more than 1 unit away at all times.

    I'm not sure what else to post, but I'm using a version of unity that's the most recent within the last 2 weeks or so, and my HDRP version should match the unity version. I believe ray tracing is off. Thanks in advance for the help!
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,057
    Might I ask why you use the HDRP?
    It's generally used for games with ultra realistic quality or if your game needs certain features. In general it is slower and will limit the amount of Platforms you van use.
    In URP there is a setting in the URP settings called depth bias and normal bias. Changing these would fix the issue. Not sure about HDRP.

    The issue is probably caused by the player's hat not being apart of the same model, or not being fully attached to the player model. Then light can slip in between the hat and player
     
  3. mike11986

    mike11986

    Joined:
    Jul 23, 2018
    Posts:
    24
    Good question! I'm using HDRP because I'm using the physically based sky. I'm deep into HDRP at this point, so I wouldn't want to try to change platforms. This is sort of me playing around and learning as I go, maybe making a game in the process or maybe never releasing anything. I'm not an artist and don't pretend to be, but I did learn how to use blender!

    When I watch the video, it doesn't really seem like light slipping between. The top of the hat gets cut off later, and it's especially weird when it straight up stops casting the shadow from the player's eyeballs. The hat has such a wide brim that it should be casting a shadow on the player's head, but it does appear that right about the time the camera can no longer see that, that's when the shadow acts up. By why make the eyes disappear or part of the hat? It's like certain positions of objects stop casting shadows when they are a very specific distance from the light, but as I said in my OP, the camera is setup that it shouldn't neglect distances from say 1.4-1.5 without neglecting any other ones.

    I think I may have a theory. The player's angle is manipulated by a shader so as to make the player's perspective to the camera better. I've seen it used in other games, such as Zelda Link Between Worlds. The shadow does seem crafted from the angled render of the mesh, so maybe that has something to do with it.
     
  4. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    It looks like you are using an orthographic camera ?
    Be aware that orthographic camera rendering is not supported in HDRP.
     
  5. mike11986

    mike11986

    Joined:
    Jul 23, 2018
    Posts:
    24
    Hmm, I wasn't aware of that, but the issue still occurs in perspective mode also.
     

    Attached Files:

  6. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,667
    What??? why?
     
  7. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    I'm wondering if this could be an issue with wrong shadow culling from one side to the other of the point light shadowmap.
    Could you make a bug report with your scene please ?
     
  8. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    It's not like it doesn't work, but it will lead into some rendering issues, in particular with lighting on transparent objects.
    HDRP was build for realistic rendering, and orthographic camera isn't really something realistic, so it was voluntarily ignore for optimisation of some algorithms.

    See "Projection" on this doc page :
     
    Last edited: Sep 7, 2022
  9. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,667
    yeah i though that but what if some one wants to make an orthographic game with "realistic" graphics or something with nice effects that only works on HDRP?
    not supporting orthographic cameras is something very weird for HDRP, the full featured version of the engine
     
  10. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,057
    He explained it quite clearly. Hdrp isn't the fully featured engine. Its one out of two premade render pipelines aimed at being the most realistic possible. Orthographic projection isn't that.
    URP does support it since it's built for cross platform, performance and ease of use.
    The HDRP source is on git and you can make your own SRP if you need to change hdrp code to make orthographic support better
     
  11. mike11986

    mike11986

    Joined:
    Jul 23, 2018
    Posts:
    24
    So just for the sake of argument, is there a good substitute in the URP for the physically based sky and the cloud layer? I'm not using the volumetric clouds.

    Sent, thank you!
     
  12. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    Sorry, I forgot to answer earlier, but if you have the bug case ID handy and could share it here I'd be curious to look at it.
     
  13. mike11986

    mike11986

    Joined:
    Jul 23, 2018
    Posts:
    24
    I believe you're looking for this: IN-16028

    Thanks again for looking through everything.
     
    Last edited: Sep 20, 2022
  14. mike11986

    mike11986

    Joined:
    Jul 23, 2018
    Posts:
    24
    I got an interesting response that this issue actually is as designed:

    This is by design because the bounds of the renderer don't match what the rotated mesh will be due to the shadergraph based rotation. I suggest the user to create a custom render bound for the character that have that shader applied so that the rotation applied in shader will be accounted for by the culling (see https://docs.unity3d.com/ScriptReference/Renderer-bounds.html )