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

8-bit style shadows in Unity3D

Discussion in 'General Discussion' started by elmar1028, Jun 2, 2014.

  1. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,353
    Hey guys,

    So I saw this game:



    Notice the shadows type - not like traditional realistic Unity shadows.

    This game is made in Unity3D engine. I am wondering how did he manage to get pixel shadows and how is it possible to make 2D objects have shadows.

    Anyone have ideas?
     
  2. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,196
    I think that maybe the shadows is just part of the sprites...
     
  3. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I have those in The Other Brothers, they're just generally rendered sprites. If you want Unity's shadows to render like this, then simply set your sprites to alpha test / clip. Should be the same.
     
  4. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,353
    Nope. Checked it. They're actually shadows rendered by Unity.
     
  5. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Then they will be the same, just use alpha test instead of alpha blend. This isn't remotely good on mobile hardware though, and you should use sprites for mobile hardware, mostly because of the hit from alpha test. You could mix and have only the casters use alpha testing because alpha blend isn't capable of working with shadowmaps.
     
  6. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,196
    Well, like @hippocoder said, if you're going to publish on mobile this is a bad idea, if using alpha test alone is already a heavy thing on mobile now imagine alpha test + soft shadows (at least on the video they look soft). I would put the shadows on sprites on both alternatives, it would allow me to do a more customized shadow.
     
  7. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,353
    How do you do it?
     
  8. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I created a component that can be dropped onto any GameObject. Then it simply creates a reference to the gameobject mesh, and uses drawmesh to draw a duplicate with suitable shadow shader with lazy raycast for Y, and orient to surface normal.

    Worked perfectly well for most floor types.