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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Shadowed PBR objects still display specular 'reflection'

Discussion in 'General Graphics' started by GoGoGadget, Apr 13, 2015.

  1. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    855
    Hi,

    First off, apologies if my terminology is incorrect, but basically, I've run into a bug after switching over from Lux + Sunshine in Unity 4, to default Unity PBR + Shadows in Unity 5, not sure if this is intended, or if there's any way to fix it.
    http://imgur.com/EAwms3U,byF5ptF
    As you can see, when shadowed, the reflection/specular highlight of the directional light still displays. Previously, in Unity 4 with Lux/Sunshine (not sure which affected it), this specular highlight would (as expected) not be displayed, ie: http://i.imgur.com/iSXETZh.jpg

    So, is there any way to make shadows in Unity5 cancel out any specular/BRDF/whatever the correct term is highlight?
     
  2. OllyNicholson

    OllyNicholson

    Unity Technologies

    Joined:
    Jun 17, 2011
    Posts:
    142
    This depends on your scene lighting settings - even in shadow an object can still receive some specular highlight from the indirect (sky) light. Simply reduce the ambient intensity from the Lighting panel. If you have a static object then it can also depend on the General GI: direction Mode. If it is dynamic you will want to place some lighting probes to enable you dynamic object to pick up lighting, shadows and GI including specular. Further info can be found here:

    http://docs.unity3d.com/Manual/GIIntro.html
     
  3. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    855
    This isn't related to ambient lighting (still occurs with ambient at 0/any value), it's exactly where it would be as a highlight from the directional light, and the highlight looks very unnatural/out of place - here's a better example: http://imgur.com/QjuxeZa
    Light probes don't change this, and I'm not using GI at all.
    You can't see the sun's reflection on an object when it's in shadow, so why is this the standard here? Feels like a big step back to what 3rd party solutions can already do with Unity 4...
     
  4. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    855
    @OllyNicholson So, just to double check, this is intended behaviour, and just there for mobile performance reasons? Also, what would I have to look at changing to get this fixed (eg, would it be possible to fix it by editing the standard shader?)
     
    Last edited: Apr 17, 2015
  5. Findus

    Findus

    Joined:
    Jun 23, 2012
    Posts:
    111
    Could be the standard reflection probe if you didn't adjust that. The standard mat uses that.
     
  6. OllyNicholson

    OllyNicholson

    Unity Technologies

    Joined:
    Jun 17, 2011
    Posts:
    142
    Findus raises a good point - PBR (Standard Shader) materials reflections fall back to the skydome if there is not specific reflection probe - as defined in your lighting settings, the power of which is dependent on the physical material properties (Gloss/Spec/Metallic). You can drop reflection intensity to zero in the Lightmapping pane to check. Then to remedy this to be more physically correct properly you would add a reflection probe at this position, which if mostly in shadow would have the bright parts of the environment occluded, you could also adjust your material bitmaps or slider values accordingly to eliminate reflections if you do not want them for this material. For more info check this blog:

    http://blogs.unity3d.com/2015/02/18/working-with-physically-based-shading-a-practical-approach/
     
    theANMATOR2b likes this.
  7. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Sorry for resurrecting this post but I had a similar question... is there a way, without using a bunch of reflection probes, to just have the shader dim (or remove) the reflection if it is in shadow? Is there a way to modify the Standard Shader to have it basically use a reflection intensity of 0.1 or just zero for pixels that are being affected by a shadow?
     
  8. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,453
    I have this same problem. Turning off environment reflections, changing intensity to 0, it doesn't matter. This seems like a bug.

    Here you can see the problem really bad with my 100% smooth black material.

    Here is the sun behind a pillar, the ground is black, 100% smooth.

    upload_2019-3-21_11-20-36.png

    And the reflection below the pillar, which is in shadow, you can barely see the shadow outline but it is there.

    upload_2019-3-21_11-21-1.png
     
  9. Henry_Sun

    Henry_Sun

    Joined:
    Jun 1, 2019
    Posts:
    23
    Sorry for bumping up this post again as no actual reason is answered.
    I think the reason why PBR doesn't mask out the specular highlights in shadows is it can't tell which shadow is casted by which light in the default render pipeline.
    Let's imagine scenes like these:
    The ball is in the second point light shadow but it should have highlights from main light.
    Snipaste_2021-12-22_16-36-00.png
    And vise versa. The ball is in the main light shadow but should still have highlights from the second light.
    Snipaste_2021-12-22_16-42-06.png
    So in this situation Unity think you should use reflection probe to weaken the wrong highlights.
    (UE4 also uses SSR to do it)
    Well if you ensure you only got one directional light, you can just remove the highlights in shadows.

    But in theory we CAN tell which shadow is casted by which light because they are calculated from different shadowmaps.
    But the render pipeline is mixing all the attenuations into one value.
    Maybe they will fix this or maybe it's not worth fixing.