How to calculate shadow correctly after vertex deformation in shader graph URP?

Hi all. Thank you for coming.

I have noticed that after vertex deformation, all the shadow (also the normal node) are still calculated based on the original mesh. So the shadow/specular for the deformed mesh are not correct. I have read some posts talk about this in shader code. I know almost nothing about shader code. So I wonder is there a way to calculate shadow dynamically base on the deformed mesh? Or is there a way to get the deformed normals in SG?

By the way, I am using URP. I am working on a cloud shader where the surface of the cloud deforms dynamically. It’s looking poorly without the correct shadow.

Thank you everyone in advance!!

I came across this brilliant video that explains how to recalculate normals after vertex deformation in shader graph. There is a repo linked in the video description.
I’m not sure about the shadows though.

I hope this helps!
M

This video is so brilliant. Thank you for sharing. It’s just a perfect fit for my situation.

The video’s title is too humble lol. It does something way higher level than just calculate normal IMO.

You saved my day. Thank you man!

1 Like