Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
282 views
in Technique[技术] by (71.8m points)

unity3d - Unity URP casting the wrong shadow

I am using Unity 2020.1.13f1c1 and I am currently experiencing some shadow casting problems where the wrong shadow is cast. When I enter play mode in Editor, this happens.

PlayAnimationInEditor_PlayMode

The shadow of the character body becomes the shadow of the head for the first key frame in my animation. But it does not happen in Editor when I play the animation without entering play mode. The shadow is normal there.

PlayAnimationInEditor

The body and the head are 2 seperated GameObjects(Quad) under one GameObject. And here is the ShaderGraph for the material I am using for both GameObjects.

ShaderGraphForManualAnimation

Also, I notice that if I move the head away from the range of the Spotlight, the shadow is normal again.

MoveHeadOutofSpotlight

Could anyone help me with this? Is there anywhere I could have done wrong? Or is this a glitch in Unity? Or maybe it has something to do with the fact that I upgraded the project from an older version of Unity to 2020.1.13f1c1?

[This issue is also posted on Unity Forum]

----------Update 26/1/2021----------

FrameDebug reveals something strange. The rendering pipeline is actually using 2 different textures for shadow and opaque rendering. In shadow rendering pass, it uses the texture for the head. But in opaque rendering pass, it uses the texture from the body. ShadowPass

OpaquePass

I am not very familiar with the insides of URP rendering pipeline, but how is it possible for the pipeline to switch the texture for the same mesh between shadow rendering pass and opaque rendering pass?

question from:https://stackoverflow.com/questions/65885632/unity-urp-casting-the-wrong-shadow

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Nvm it seems to be a Unity project auto-upgrade problem. Redoing animation solves it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...