Hi guys, I have an issue and i can’t find the answer by myself :
I want a Game object not to receive is own shadow but to cast one and to receive the shadows of others Game objects.
Here’s an example with Cast Shadows & Receive Shadows on :
And here’s the visual result I want (Receive shadows is off) :
The problem is, the mesh doesn’t receive is own shadow but neither it receives the shadows of others meshes !
I did find a clumsy solution you can see below. I added a plane with Shadows Only underneath my canopy and I deactivated Cast Shadows for my canopy. The result is : the mesh receives shadows but doesn’t cast one, however the shadow only plane does cast the shadow on the ground. This is a good result for me but it won’t work for all sort of meshes and it’s not ideal.
I use a dynamic directional light (day/night cycle).
Changing the emission of the material does not produce a good result.
Some help is welcome here 
The question of disabling self-shadowing has been asked before and the answer has always been that it’s not possible. So I don’t think there’s a simple solution.
That’s unfortunate because it could be quite useful for some art directions 
If someone think of another solution besides an invisible mesh casting shadows…
I thought a shader could help, if someone knowlegable with shaders pass by !
The way it works is that the system generate a depth map (the shadowmap) from the light position, and use that to test pixel rendered, basically looking if the world position of that pixel is below the world depth of the shadowmap, ie it is being occluded by another objects in front of the light.
- In order for your object to not cast shadow, it must not be rendered on the shadownmap pass
- if it’s rendered on the shadow map pass, then the object shader will just compare to the shadowmap
Therefore in order to disable self shadowing but still cast shadow:
- you must render the object on the shadow pass
- disregard writing the shadow pixel in the object shader
Problem doing the second option mean no other objects can cast shadow on the object. That would mean:
- to receive shadow, you must enable the shadowmap but not have the object rendered which defeat the object casting shadow
- to disable shadowmap, you must discard shadow test but then other objects won’t be able to cast shadow.
So the solution would be to have multiple pass:
- 1 one pass render the object to the shadow map, but disable shadow test to allow casting but disable self shadow
- the second pass don’t render the object to the shadow map and therefore enable other object to cast shadow but without the object self shadowing, and the object shadow casting is already one in pass 1.
Obviously that would expensive, so the real solution would be to find alternative to one or the other pass.
- You could replace the reception of shadow by a custom system that would capture environment from the object perspective, that would work well if you have just a very small number of objects
- For tree and repeated object in great number, having another solution need to be design certainly.
The solution is not trivial and the thing you did is maybe the way to go, except each object type would need a custom solution.
Thx for your detailed answer ! I think I understand better the way the shadows are generated at least !
Yeah, the multipass solution is probably too expensive and unfortunately, it’s for a large amount of GameObjects (vegetation argh). I will try to achieve this with a custom solution.
I’m very curious because it’s a very nice visual result for vegetation I think, and this the way vegetation is rendered in The Witness & Rime I think !