Search Unity

Unity Roadblock. Self-Shadowing Without Casting Terrain Shadows

Discussion in 'General Graphics' started by stonstad, Oct 3, 2019.

  1. stonstad

    stonstad

    Joined:
    Jan 19, 2018
    Posts:
    660
    Has anyone come up with an elegant and performant solution to this problem? Unity 2019.2.x, standard pipeline.

    Here's my ship cockpit. The cockpit casts a self-shadow on part of the cockpit interior, including the console near the right side. I think it looks pretty good but you can see the cockpit's shadow also appears on terrain.

    I'd like to hide the cockpit shadow on the terrain while retaining self-shadowing.

    Original, Cockpit Shadows On:



    I tried turning shadows off. That's not ideal because the interior cockpit is no longer affected by shadows, which was truly a nice effect.
    Cockpit Shadows Off:



    So then I decided to draw the actual starship with MeshRenderer mode set to Shadows Only.
    Cockpit Shadows Off, Starship Shadows Only



    ...So now the shadow on the ground is nice but the entire cockpit is dark.

    Is there some kind of mask or layer feature that I can apply here? Or do I need to two cameras with layer masks? So many questions... Is there perhaps a Unity feature I may use?

    Thanks,
    Shaun
     
    Last edited: Oct 3, 2019
  2. mouurusai

    mouurusai

    Joined:
    Dec 2, 2011
    Posts:
    350
    Try to exclude terrain layer from the cockpit light culling mask.
     
    stonstad likes this.
  3. stonstad

    stonstad

    Joined:
    Jan 19, 2018
    Posts:
    660
    Two lights! (slaps forehead). Thank you -- that's perfect. I'll have the second light mirror the position/rotation of the first. Thanks man!