Disable shadows on a Lit object

I want to make a Lit object, that casts shadows, not receive shadows from other objects.
A mockup edited in Photoshop of what I’m trying to achieve(the one on the bottom):


I’ve searched quite a bit on the forums, but the threads are a bit old, and none of the solutions suggested worked for me.

https://stackoverflow.com/questions/63596790/unity3d-how-do-you-turn-off-receive-shadows-in-a-shader-made-with-shader-gra
Enabling Debug Mode and disabling “Receive Shadows” on the object can be done but doesn’t work in HDRP.

Suggests disabling Contact Shadows, not related, doesn’t do anything.

Suggests adding the _RECEIVE_SHADOWS_OFF keyword on a custom Shader Graph. It is possible to do so however it didn’t change anything whatsoever.

Suggests that you can achieve that using Light and Shadow Layers.
After playing with the Layers for quite some time, I’m almost sure that it’s impossible to get the behavior I wanted with Light and Shadow Layers.
The way they seem to work to me is that Shadow Layers dictate which objects will cast shadow, and Light layers dictate which objects will receive both Light and Shadow.
The behaviors of receiving light and receiving shadow seem inherently coupled together on Light Layers, so it’s impossible to make something which receives light but not shadow.
You can make something affected by a certain Light not cast shadows by switching the Shadow Layer, but you can’t make an object affected by a certain Light not receive the shadows cast by that certain Light.

Is there any way to achieve that effect on the bottom with any other feature in HDRP, or is there something I’m missing about Light Layers?

Should note that the closest that I managed to get to the effect I wanted was to duplicate every light on the world, make them only affect Layer 2, and not cast any shadows. Then on the original lights, make them only affect Layer 1 but cast shadows for both Layer 1 and 2. Put objects that shouldn’t receive shadow in Layer 2.

It technically works just like I wanted it to, minus the obvious performance implications of duplicating every light in the scene, so I was wondering if there is a better way.

likablecalculatingcheetah

Could probably achieve a similar effect do an Unlit Shader with Blinn–Phong shading, that wouldn’t be affected by cast shadows, but it also wouldn’t have many of the features from the Lit shader. I really wanted a way to have a Lit shader without cast shadows affecting it.

duplicate mesh, position it at the exact same spot (or event parent it under the primary one), and set it to “Shadows Only” + disable shadows on the original, visible mesh.

The issue is that I do not know a way in HDRP to disable shadows on the original visible mesh without also disabling light.

If I make it Unlit then it will not receive any light.
If I put it at a Light Layer that doesn’t contain the scene lights, then it will not receive any light and will be pitch black.
If I put it at a Light Layer that does contain the scene lights, then it will receive light, but also shadows.

You can do so on the Mesh component under Lighting/Cast Shadows. The configuration there works in HDRP.
Otherwise see @nehvaleem 's answer, that’s the easiest way to achieve that effect, you don’t even need light layers.

That configuration doesn’t keep the mesh from getting affected by cast shadows, it only keeps the mesh from casting shadows. It doesn’t help to achieve the effect that I want, since the mesh is still affected by shadows, as you can see from below:

Shadow Caster configuration:

Main mesh, with “Cast Shadows” off, is still affected by shadows:

The effect I want is a Lit mesh that casts shadows but is not affected by cast shadows:

There is a “Receive Shadow” toggle on there if you activate Debug mode, and that toggle would solve all my problems, except that it doesn’t work on HDRP. It doesn’t do anything, as you can see even with it toggled off the mesh still receives shadows.

Ah I see, thanks for clarifying. Have you tried using Mixed Lighting? If you bake Light Probes or Adaptive Probe Volume before adding your shadow caster and have your Sphere being lit by probes only with an invisible shadow only mesh for the realtime shadow, it should work for your use case, I think.

I haven’t tried it, I think that it’d work for the interiors, but it’s a game with dynamic time of day, so I wouldn’t be able to do that on the world scene.

Did you find a good solution?

1 Like

https://stackoverflow.com/questions/63596790/unity3d-how-do-you-turn-off-receive-shadows-in-a-shader-made-with-shader-gra

Just wanted to post as an update that as of right now the “Recieve Shadows” option is located on the material itself. Just in case you cant find it in your renderer.

1 Like