Hello, I am using some spine 3.8 objects in Unity 2019 with Universal Rendering Pipeline/2D/Sprite-lit-default shader, everything seems to work fine but when I raise sensibly the 2d light some parts of the object are enlighted just less than what I expect.
Here are some screens of a little bat to explain the issue: in the first i have light intensity around 5, the I rise it to show the visual artifact, the middle part gets the light correctly, the body and the ears stay dark and reacts to a far light threshold.
Probably it's working as it should do, but i'd need to understand what can I do to mitigate this effect.
Light2D on spine material
- Изменено
The issue you're experiencing with the 2D light on your Spine objects in Unity using the Universal Rendering Pipeline/2D/Sprite-lit-default shader is likely due to the vertex-lit nature of the shader. This can cause certain parts of the object to receive less light than expected, especially when dealing with large attachment images or specific lighting conditions.
To mitigate this effect, you can try the following solutions:
Switch to a Pixel-Lit Shader: Use a pixel-lit shader such as
Spine/Sprite/Pixel Lit
or any of the URP shaders specifically designed for Spine. This can provide more consistent lighting across the entire object.Adjust Lighting Settings: Modify the lighting setup in your scene. Ensure that the light source is positioned and configured to provide even illumination across the entire object.
Increase Attachment Geometry: Add more vertices to the attachment geometry. This can be done by converting the
RegionAttachment
to aMeshAttachment
, which allows for more detailed lighting calculations.Check Normals and Tangents: Ensure that the normals and tangents are correctly set up for your Spine objects. This can affect how light interacts with the surfaces.
Here is an example of how to switch to a pixel-lit shader:
// Assign the pixel-lit shader to your material
Material material = new Material(Shader.Find("Spine/Sprite/Pixel Lit"));
yourSpineRenderer.material = material;
Additionally, you can refer to the Spine URP Shaders UPM package documentation
@luigi7 Please note that Universal Rendering Pipeline/2D/Sprite-lit-default
is not a Spine-specific shader.
You may want to check out the Spine URP Shaders UPM package for details, as Spinebot mentioned.
However, there are no separate vertex-lit vs pixel-lit URP shaders available in the package. Instead for URP you can configure whether the respective lights are evaluated as per-pixel or per-vertex in the RenderPipelineAsset
settings (e.g. see Example 2D URP Asset
which comes with the Spine URP Shaders UPM package under Samples in the Package Manager).
I took my time to do some experiments: tried with a straight alpha and premultiplied, using Universal Rendering Pipeline/2D/Spine/Skeleton Lit and I have the same effect: that particular object gets the 2dlight as other spine objects in the scene, but needs more intensity to get brighter... it seem it some sort of threshold that it reaches only with higher intensity light.
By luck it is not a huge problem, I can just dodge it tuning the light to make it not noticeable, but I'm trying to understand.
Do you mean this?
@luigi7 Yes, thanks. These settings look correct.
I then assume that the issue might be with faces being backfaces and normals pointing away from the camera instead of towards it. What are your settings at the Material
, what settings at the SkeletonAnimation
component under the Advanced
section? Please be sure to enable Fixed normals
and let them point in (0, 0, 1)
direction. Then also disable Advanced - Generate Normals
at the SkeletonAnimation
component.
If that's not resolving your issue, could you please send us a minimal Unity project which still shows this issue? You can send it as a zip file to contact@esotericsoftware.com, briefly mentioning this forum thread URL so that we know the context. Then we can have a look at what's going wrong.