Search Unity

Shadows in Unity

Discussion in 'Shaders' started by zoran404, Apr 13, 2015.

  1. zoran404

    zoran404

    Joined:
    Jan 11, 2015
    Posts:
    520
    Is there a good tutorial on how to handle shadows in shaders?

    I'd really like to learn how to do this manually, so I could create some effects. But I can't find good tutorials anywhere.
     
    Ben-BearFish likes this.
  2. colin299

    colin299

    Joined:
    Sep 2, 2013
    Posts:
    181
    what kind of shadow do you want to learn?
    I know 4 kind of shadow solution currently.

    static - unity light mapping? (e.g. building)
    dynamic - unity shadow mapping? (e.g. character)
    dynamic - shadow volume?(hard shadow that works for any surface)
    dynamic - planar projection shadow? (only works on flat ground, but easy to write shader code and good performance)
     
  3. zoran404

    zoran404

    Joined:
    Jan 11, 2015
    Posts:
    520
    I'm intending to learn all of them. If you're willing to assist me.
     
  4. colin299

    colin299

    Joined:
    Sep 2, 2013
    Posts:
    181
    Maybe start by the most simple shadowing first.

    Planar projection shadow:
    I
    t only require you to add a bit extra code into the shader code that your object is currently using.(e.g. your original custom shader)
    it use an extra pass, render an object in transparent shadow color again, but the vertex position are "projected" on ground.

    Result (from the project I am working on):

    I am typing the shader that you can use directly in the next reply, it will takes some time.
     
  5. zoran404

    zoran404

    Joined:
    Jan 11, 2015
    Posts:
    520
    Oh cool.
    You're the best! ^_^

    Btw what is this game that you're making?
     
  6. colin299

    colin299

    Joined:
    Sep 2, 2013
    Posts:
    181
  7. zoran404

    zoran404

    Joined:
    Jan 11, 2015
    Posts:
    520
    So you're making a toon shader. Does it use real-time shadows or are shadows in the texture?
     
  8. colin299

    colin299

    Joined:
    Sep 2, 2013
    Posts:
    181
    it is real time, just cel shading