How to create a shadow in URP and HDRP shader (Unlit)?

Hi!

I have a shader that works in both URP (v. 7.3.1) and HDRP (v. 7.3.1).
But I would like it to cast a shadow according to its shape.

It would seem that the problem seems simple, but I have not found a solution. :roll_eyes:

I found the answer here, but I can’t change properties Alphacrypt light and Opaque.

Cast shadow of transparent plane in URP

How do I display the simple shadow from the shader on the terrain (and on other objects in the scene)?

Thank you!

The easiest method would be to just duplicate the object, make it use opaque and alpha clip, then set the shadow mode in its mesh renderer to “Shadow Only”.

Hope that helps. :wink:

1 Like

Thanks! I’ll try. :slight_smile:

Now I’m reading this discussion.
Shadow and distance attenuation do not work in URP Unlit Graph
https://discussions.unity.com/t/771097

Can you tell me? How can I add my code to .shadergraph file? Is it possible?
Maybe I need to compile it in .shader? But compiled files give errors and are not a file with the correct shader code, as I understand.

AAA… I see! I can use Custom function and Keywords… :):):slight_smile:

I tried to implement everything they say here, but it didn’t work.:(:(:frowning:

Shadow and distance attenuation do not work in URP Unlit Graph
https://discussions.unity.com/t/771097

Shader Graph Custom Lighting (Shadows for URP Unlit Graph)
https://cyangamedev.wordpress.com/2020/09/22/custom-lighting/

Custom Lighting in Shader Graph: Expanding your graphs in 2019
https://blog.unity.com/technology/custom-lighting-in-shader-graph-expanding-your-graphs-in-2019

I created a Custom Function, created nodes of Light source - but it doesn’t work to attach them to the Color output in Unlit - there is no shadow and everything looks terrible (I tried Lerp, Multiply, Add, Blend).

I’ll probably have to follow your advice… :):roll_eyes:

Everything worked

https://www.youtube.com/watch?v=dBevLmyWR3o

Thank you a lot!

The question is closed!

1 Like

How did you get this working? Did you manage to get unlit graph to pick shadow attenuation of main or other light? All of those tutorials seem to suggest it can work but none appear to actually work, shadow attenuation is always 1!!