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

Cast Shadow but not render the mesh?

Discussion in 'General Graphics' started by GainfulSage, Sep 16, 2020.

  1. GainfulSage

    GainfulSage

    Joined:
    Apr 30, 2015
    Posts:
    106
    Hi -

    I'd like to have an invisible enemy that the player can only see via the real-time shadow. Any ideas for how to set that up?

    Even a simple capsule shadow would be sufficient. Setting the alpha in the material for the standard shader with Fade or Transparent doesn't work - the shadow disappears too...

    Thanks!
     
  2. naiwen_xie

    naiwen_xie

    Joined:
    Mar 11, 2017
    Posts:
    12
    I think you need a custom transparent shader to do this job.
    Something like:

    alpha_value = 1.0f - Light.Attenuation;

    But some cases like if the enemy is half in the shadow, half out should be cared about.
     
  3. GainfulSage

    GainfulSage

    Joined:
    Apr 30, 2015
    Posts:
    106
    Hmm. Any options other than a custom shader? So far I've been loathe to go there... o_O
     
  4. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,469
    hide the object to the rendering camera by setting the camera layer
     
  5. GainfulSage

    GainfulSage

    Joined:
    Apr 30, 2015
    Posts:
    106
    Tried that, the shadow disappeared too.
     
  6. mouurusai

    mouurusai

    Joined:
    Dec 2, 2011
    Posts:
    349
    MeshRenderer->Cast Shadows->Shadows Only
     
  7. GainfulSage

    GainfulSage

    Joined:
    Apr 30, 2015
    Posts:
    106
    @mouurusai - that worked perfectly! Thank you!

    I wish there was an option to give Gold or points or something. :)
     
    marce155, kloogens, tantx and 5 others like this.
  8. Ary-Guilherme

    Ary-Guilherme

    Joined:
    Feb 27, 2018
    Posts:
    3
    @mouurusai - I forgot that option in MeshRenderer, thank you for help!
     
  9. mrrusby

    mrrusby

    Joined:
    Aug 25, 2021
    Posts:
    7
    with volume lighting turned on the shadow seems to disappear also - using HDRP.
    I have had it working previously, so am not sure
     
  10. TimurKE

    TimurKE

    Joined:
    Jun 24, 2022
    Posts:
    1
    when postprocessing, the character becomes a living shadow, how can this be fixed?
    upload_2022-8-23_21-52-48.png
     
  11. KickPackStudios

    KickPackStudios

    Joined:
    Jun 20, 2021
    Posts:
    4
    THNX! i have been looking for this since past two days and finally my problem has fixed:)
    I am extremely Happy