How to make transparent surface object has a shadow?

Hello top-men.

I’m new in shaders and I want to make a top-down style game.

So I want to make the object between the character and the camera transparent but still keep its shadow.

So how can I do that in URP?

Thanks.

One way would be using two objects: One that is transparent, and a duplicate with an opaque material that is set to “Shadows Only” in the Lighting settings of the Mesh Renderer.

Hello, thank you very much, is this likely to degrade performance? I means there need double meshes here.

Thanks.

A mesh with real-time shadow is drawn (at least) twice, anyway, so I doubt it, because the “Shadows Only”-Mesh is not drawn by the main camera. A quick test showed that this setup resulted in the same number of batches as with normal shadow-casting objects. And even if there was a difference, unless the total number of objects is very high, it should not matter at all.

Thank you very much~~! I will test again in my scene.