• Unity
  • Unity Receive shadows

Related Discussions
...

I'm sorry if this has been answered elsewhere but I'm scratching my head for how to get the spine shader to receive shadows.
Basically I have a 2d character in a 3d environment. Casting shadows works well but - as mentioned- can' figure out how to receive shadows. I'm fairly new to Unity so apologies if there's an obvious answer.

I should probably mentioned the problem exists in both normal and universal render pipeline.

Thanks!

No need to apologize. You can use the Spine/Sprite/Pixel Lit shader if you need to receive shadows, as it is the only one which samples lighting data per-pixel (in terms of evaluating LIGHT_ATTENUATION and LIGHTING_COORDS in the shader).

Be sure to enable Fixed Normals if you see your character not catching any light. You can check out the Spine Examples/Other Examples/Sprite Shaders example scene (although it's using the Spine/Sprite/Vertex Lit shader, they are quite similar).

Hi Harald, I'm afraid that hasn't worked - now the character is all pink?! I can't tell where the problem is. I'm using the universal render pipeline, and updating the material doesn't help. Any ideas?

I downloaded the latest URP Shaders UPM package from spine FYI

p.s.
"You can check out the Spine Examples/Other Examples/Sprite Shaders"
Also all pink and Unity can't update material (There's no upgraded to convert .... to selected pipeline).

Is there some additional step need to get Spine and URP to work?

Thanks Harald for trying to help me with this.
Unfortunately, I still can't seem to get it to look good.
I went through all the option in the various list for URP/Spine/2d/Sprite and then all the setting for each and the best I can get is this. (see image)
I expected it to look like a 2d plane being hit with a basic shadow (i.e. if I stand with the bottom half of the character in shadow, I would expect to see the top half in light) but instead, I get this overall black blurry effect on the character - even standing in the middle of an open room (no roof). When moving into shadow it slowly (delayed) darkens the character and then when moving back into the light it never really comes back to the original lighter state.

I don't know - I thought it would be a fairly straight forward thing to do from a user point of view. Am I missing some basic step?
Is there something that needs doing to the light (just a directional light at the moment).

(after taking that 1st screen grab) I started playing around with shadow cascades and any other shadow settings I can find but it doesn't seem to help much on the character itself. (in case it's relevant I built the scene in 'real' size e.g. 1m is 1unity unit).
If anything, it seems to be making it worse (the shadow on the ground look better but character goes fully dark when wandering in the direction of shadows on the left of screen).

*Also blend modes seem to no longer work (I had a blend mode ('add' off the top of my head) asset on here body now seems to be treated as no blend)

Thanks again for your help!

DutchyB wrote

I went through all the option in the various list for URP/Spine/2d/Sprite and then all the setting for each and the best I can get is this. (see image)

Why are you using URP/Spine/2d/Sprite shaders?
What Render Pipeline Asset do you have assigned (Quality settings)?
See this other thread here with similar problems:
Post Processing with URP not working with Spine Assets

Most likely you want to use the 3D URP shaders, not the 2D URP shaders.

Regarding additive blend mode:
Did you assign the blend mode materials via the SkeletonDataModifier as described here?

Hi Harald,

Why are you using URP/Spine/2d/Sprite shaders?

Just so we're on the same page - what I meant if that I selected, 1 by 1, every shader option that seemed remotely likely under each tree.
e.g. Shader>Spine> Blend Modes / Special / Sprite / Skeleton / Skeleton Fill...
Then Shader>Universal Pipeline> 2d / spine / lit / simple lit / unlit....
Shader>Sprite>....
And then tried changing relevant settings.

What Render Pipeline Asset do you have assigned (Quality settings)?

I'll do my best to answer this one as I haven't got my head around this.
Currently as far as I'm aware - none.
I switched to URP because I couldn't get shadows to work and, supposedly, URP is better + the makers of unity want everyone to use it, right? Plus you can add post effects, which might be nice later. I haven't added any effects yet.
I went to the universalRenderPipelineAsset and set cascades and set the shadow resolution higher. The shadows have improved but how they interact with spine has gotten worse. I only have 1 directional light in the scene no change to settings (soft shadows).

Most likely you want to use the 3D URP shaders, not the 2D URP shaders.

Not 100% sure how to tell from the drop downs if it's 3D or not but as mentioned -feel like I've tried them all.
as you can see from previous post URP/Spine/Sprite/Lit universal is what I'm currently using.

Regarding additive blend mode:
Did you assign the blend mode materials via the SkeletonDataModifier as described here?
No I did not - as you can see in the below, she has a shine on her hip - it's just 1 glowy blob to make her hips look like they swing back and forth a bit more with animation. I works in Shader>Spine/Skeleton and some others.
It's not really a priority considering I can't get shadows to cast on the character so I'm not going to dig into this now.

Would it just be easier to untangle from URP (not 100% sure how to turn it off - unfortunately I work16hr shifts at the moment so have limited time to work on my game 🙁 )

Again I really appreciate your time! Thanks,

Oh dear, I just noticed that the URP/Spine/Sprite shader Receive Shadows functionality is simply broken. While in the normal render pipeline Spine/Sprite/Pixel Lit is receiving shadows, using 3D URP pipeline it is not receiving them correctly. Sorry for the troubles!

I have created an issue ticket here:
[unity] URP Sprite shader not receiving shadows · #1726
I will get back to you as soon as the issue is resolved.

Thanks for reporting!

DutchyB wrote

Would it just be easier to untangle from URP (not 100% sure how to turn it off - unfortunately I work16hr shifts at the moment so have limited time to work on my game 🙁 )

Oh dear, please also leave some time for sleeping.


Hm, for strange reasons it seems to be required to assign vertex normals at the mesh. After enabling SkeletonAnimation - Advanced - Add Normals the shadow is received as desired without any other modifications. We will further investigate why that is the case, but for now please disable Fixed Normal and enable SkeletonAnimation - Advanced - Add Normals.


Unfortunately we did not find any documentation mentioning the requirement and could not find any side effect which might explain it.
So as a fix, please enable SkeletonAnimation - Advanced - Add Normals to receive shadows. You may then want to disable Fixed Normal.

A warning box has now been added at the SkeletonRenderer inspectors which warns of this problematic combination.
A new unitypackage is available for download here as usual:
esotericsoftware.com/spine-unity-download

Well done Harald!!

FYI for anyone who reads this in my case Skeleton Mecanim (Script) > Advanced > Add Normals.

Works perfectly!

(Fixed normals on or off didn't have an effect so left it off).

Thanks!

Glad we could solve the problem, thanks for getting back to us!