• RuntimesUnity
  • How to make spine produce shadow similar to spine shape

The game environment is 2D, and light2D is used to make the scene have lighting effects, but the shadow generated by shadow2D is too different from the shape of the actual spine. I would like to ask if there is any way to make the spine produce similar shadows

Related Discussions
...

@akeboshi Do you mean that you are using Universal Render Pipeline with a 2D Renderer setup?
What exactly do you mean by "shadow2D"?

Could you please show which components you're using (skeleton components, components for shadow casting)? Please also share a screenshot what your actual result looks like, and what you would like to see instead.

Yes, I am using the Universal Render Pipeline. I can use light2d+shadowcaster2d to achieve a rough shadow effect, but I don’t know how to project a spine model-style shadow?

@akeboshi Thanks for the additional information and the screenshot.

Please note that this question is independent of Spine and the spine-unity runtime. What should the shadow look like and how should it be projected onto a 2D plane without depth information? You may want to search the Unity forum how you can project a 2D shadow from a MeshRenderer or a Sprite, or use one of the techniques described below on a Unity how-to article on 2D lights and shadows:
https://unity.com/how-to/2d-light-shadow-techniques-in-the-universal-render-pipeline#creating-2d-shadows

If you need more precise 2.5D shadows, I would recommend switching from the 2D Renderer to the normal 3D URP renderer. Then you could utilize proper 3D shadow casting by tilting your skeleton character assets away from the ground plane.

Another way to fake a shadow that looks like the character might be to use the RenderExistingMesh component and re-render the same Spine skeleton in a scaled or distorted way with a transparent black fake-shadow material. This shadow material could use a custom shader which is set to semi-transparent black with multiply blend mode. However, to get rid of double- and triple-shadowed areas where attachments overlap you would need to render the skeleton to a render texture first. You could try the SkeletonRenderTexture example component. Unfortunately this component uses functionality which is not fully compatible with the URP pipeline, and lighting affecting the skeleton before it is rendered to the RenderTexture will be ignored and the skeleton itself will then always be fully lit (as with an unlit shader, just showing the unmodified texture).

@Harald oh! I will be doing research on this, thank you very much Harald for your suggestion。

  • Harald ha risposto a questo messaggio

    akeboshi You're welcome. 🙂