• Unity
  • Issues flipping skeleton over x-axis with lighting

  • 編集済み
Related Discussions
...

We have an entity in unity that has a child with a SkeletonAnimation component attached ('Eyeless' = Entity object, 'base' = spine object).

Before, I was handling turning around by just setting the parent scale to -1. This worked great with both the skeleton and bone following colliders. However, we decided that we wanted to add normal maps for lighting. This lead us to find that when we flipped the parent to scale -1 when a normal map is applied, the way lighting is applied to the normals appears to be working incorrectly.

https://streamable.com/pqd0ks

Now, this was fixed by using the ScaleX property on the SkeletonRenderer object to flip the skeleton. This meant however that now the skeleton was always facing the right (since the parent object turned by flipping it's scale on the x-axis). To combat this, I made the container object of the skeleton ('base' in the example picture) invert it's scale on the x-axis along with flipping the ScaleX property (a double flip essentially). This worked! Now the normal maps are behaving properly.

https://streamable.com/q0gyn3

However a new problem turned up. I was using BoneFollowers for most of the colliders of the entity and they now appear to be inverted.

https://streamable.com/aqehjc

Clearly I'm doing something wrong here; what is the correct way of doing this?

Sorry to hear that you are experiencing problems with normal orientation. In general normal and tangent generation supports negative scale at both the Transform.Scale and the Skeleton.ScaleX parameter.

I assume you are using Spine/Sprite/Vertex Lit or Pixel Lit right?
How is your normal generation setup: are you using Fixed Normals at the Sprite material? If yes, which space is selected under Fixed normal space?
If you are not using Fixed Normals, have you enabled Add Normals in Advanced section of the SkeletonAnimation Inspector?

Are you sure that you have enabled Solve Tangents in the Advanced section of the SkeletonAnimation Inspector?

Harald wrote

Sorry to hear that you are experiencing problems with normal orientation. In general normal and tangent generation supports negative scale at both the Transform.Scale and the Skeleton.ScaleX parameter.

I assume you are using Spine/Sprite/Vertex Lit or Pixel Lit right?
How is your normal generation setup: are you using Fixed Normals at the Sprite material? If yes, which space is selected under Fixed normal space?
If you are not using Fixed Normals, have you enabled Add Normals in Advanced section of the SkeletonAnimation Inspector?

Are you sure that you have enabled Solve Tangents in the Advanced section of the SkeletonAnimation Inspector?

You've put me on the right path, I realized that we were using the incorrect shader on the material. It should have been using the URP skeleton-lit shader which fixed the flipping issues. The only remaining problem appears to be that after switching to this shader, there appears to be some sort of alpha problems:

This is what the material properties look like:

If I use Skeleton-Lit, the artifacts disappear however there are no normal maps or any place to set them:

At the Skeleton Lit shader you have enabled Straight Alpha Texture while at the Sprite/Vertex Lit shader you have set the mode to Pre-Multiplied alpha.

Please be sure you understand what the PMA and Straight Alpha workflows are and how to set up your textures correctly:
spine-unity Runtime Documentation: Advanced Premultiplied vs Straight Alpha Import
I assume that your problem is based on the texture being exported as Straight alpha and that the remaining setup is not set up accordingly.

We fixed the issue, the artist had mixed up how he exported the Spine skeletons and after changing that, it fixed it. Thank you

Glad you figured it out, thanks for letting us know!