Hi, Community!
I need some advices to writing a shader or get other solution for the implementation of the intended.
So, I have a sprite that forms a character in different layers.
2d character is in 3d world, and it is necessary that he casts a shadow, reacts to the lighting and receive shadows. If the first 2 terms can be realised by a standard shader, but receive shadows can’t.
I searched quite a lot, but I did not find a correct solution. Solution from this post instead of receiving shadows only shows the shadow behind the object but not on the object.
The most suitable was this solution. But in this case, the sprite “turns” into 3d object and the order of rendering depends on the distance to the camera, but not the layer order. Because of this, it is impossible to animate the character.
However, this method is compatible with various effects such as the depth of field and the similar. Also, I can output sprites on top of all objects with “Ztest Off” and then the order of the layers will be restored.
But there are objects that should overlap the character on camera screen.Therefore this option does not fit.
In general, the option with the last shader is only one I could find where real shadows are realized. However, before using it, I need to make it suitable for my project. Namely, receiving shadows and keeping the order of rendering, depending the layer of the sprite.
It’s worth noting that I’m beginner in shaders. Does anyone know how to reach the needed result? Maybe I’m missing the kind of default implementation method?
Sorry for my English. And thank you in advance!









