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

Question Is it possible to make a sprite cast a shadow that is the shape of the opaque parts of the sprite?

Discussion in 'Universal Render Pipeline' started by DragoDude, Jul 29, 2022.

  1. DragoDude

    DragoDude

    Joined:
    Dec 3, 2016
    Posts:
    4
    I'm making an HD-2D game, kind of like Octopath Traveller, Triangle Strategy, or the new Live A Live remake. My effects look almost perfect, but when I turned on shadow casting for the SpriteRenderer the shadow was just a square. Is there any way to make the shadow the shape of the opaque parts of the sprite?
    upload_2022-7-29_11-53-18.png
     
  2. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    Yup; alpha clipping does this. If you're using default URP lit material, just check this box (and adjust the cutoff as needed):

    upload_2022-7-29_14-42-51.png

    If you're using shader graph, it's here:

    upload_2022-7-29_14-44-7.png

    If you're writing your own shader, use clip() inside the ShadowCaster pass.
     
  3. DragoDude

    DragoDude

    Joined:
    Dec 3, 2016
    Posts:
    4
    Thanks!