Shadows in Unity

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.

1 Like

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)

I’m intending to learn all of them. If you’re willing to assist me.

Maybe start by the most simple shadowing first.

Planar projection shadow:
It 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.

Oh cool.
You’re the best! :slight_smile:

Btw what is this game that you’re making?

Hello, @zoran404 .
here is the sample project of planar projection shadowing solution.
You can have a look!

the game above is just a prototype. Trying to render 3D just like 2D Japaness Animation in mobile.
It looks like this.
link

So you’re making a toon shader. Does it use real-time shadows or are shadows in the texture?

it is real time, just cel shading