- Editado
[Shader Bug] Depth write of the Spine shader and shadows
Hello people at Esoteric!.
I am using Dynamic Shadow Projector 1.0.3 and the lastest Spine in Unity 5.4
I am having a problem, this asset cant project shadows correctly on the objects animated with spine.
I wrote a mail to the author and he replied with this:
"It seems like the Spine shader doesn't write depth, and shadow is drawn over the spine object. I think, if you enable depth write of the Spine shader, you can fix this problem.
However, if your spine objects are transparent, you will have another problem. In that case you need to change the render queue of the Spine shader. The shadows rendered by Projectors have 2999 render queue value (that is "transparent - 1"). So, render queue value of the spine shader should be greater than 2999.
Also, please be noticed that Unity's Projector cannot cast shadows on transparent objects including cut-off shader, because projector shader cannot have a reference to a texture of a transparent object.
Regards,
XXXXXXXX"
So basically i have to "enable depth write" in the spine shader.
Any help?.
PS: this might be a major bug, i really need to use shadows on a mobile game and the projector is the only way.
This is a screen of the game and how the shadow doesn't project properly. Image removed due to the lack of support for HTTPS. | Show Anyway
Technically not a bug. Just an incompatible system.
Find and open Skeleton.shader in your project. It should be under spine-unity/Shaders
You probably want to backup, or only do the edit on a duplicate shader that's named differently. So copy it and save it as a different file.
Open the shader code, then look for all instances of ZWrite
and make sure it says ZWrite On
Remember to rename the shader's path on top of the shader code from Spine/Skeleton
to something else. Maybe Spine/Skeleton ZWrite
The shader is already under the transparent queue so it should be 3000 by default.
Note that ZWrite means you may have to adjust the Z Spacing slider on your SkeletonAnimation/SkeletonRenderer. It's under the Advanced
foldout box in its inspector. Otherwise, you will get Z-fighting.
Also note that using depth also means you'll have hard edges like normal 3D models, unless you have a screen space antialiasing.
You're not actually required to use Spine's shader. It doesn't do anything special. It's just there so users can use something by default.
You could use the Unlit/Transparent Cutout shader if you exported your textures from Spine with Premultiply Alpha
unchecked.
For more on that, read this page: Premultiply Alpha
The depth writing is also a standard part of ToddRivers' shader: Sprite Shaders for Unity
You only need to check the checkbox. Don't be intimidated by all the extra features. It acts like the Unity Standard Shader in that if you don't use the feature, it won't be part of the actual compiled shader at runtime so it will run without the extra cost.
Well the problem is that now the shadows are square , i can see my object , but the object projects a squared shadow