Having an Invisible Object that Casts Realtime Shadows.

In a scene, i need an invisible plane (or a box) to cast a realtime shadow.
The best way to achieve that would probably be a shader. However, i have little to no experience with shaders, so i was wondering whether there already was a shader that can do this or alternatively what other approaches can have such an effect.

EDIT for Unity 5: Now, you just have to change the Cast Shadows Mode to “Shadows Only” in the Mesh Renderer property of your gameobject.

Legacy solution for Unity 4:

I’ve seen this question asked many times, but no one gave any easy answer, although it exists…! I have been able to find it after reading a lot of forum posts and some experimentations, and here it goes :

1- add this shader in your project : (ie: copy/paste in a file named “InvisibleShadowCaster.shader” )

Shader "Transparent/InvisibleShadowCaster"
		UsePass "VertexLit/SHADOWCOLLECTOR"    
		UsePass "VertexLit/SHADOWCASTER"

	Fallback off

2- create a new material, and set its shader to “Transparent/InvisibleShadowCaster”

3- assign that new material to your Invisible shadow caster object

4- Done

As there’s only the shadow casting pass supported (1 for forward rendering & 1 for deferred rendering), you can be sure it doesn’t take any extra resource, and it’s easy to set it all up.

Here the result :


You can notice the shadow on the box under the plan, and on the bottom part of the sphere.

One way is to have your invisible object not truly invisible, but with reversed normals. That is, normals that always point away from the camera. Try this to prove to yourself: Create two default Plane objects and a directional light. Rotate the light slightly and set to cast shadows. Pull one of the planes up a bit and you will see that it is casting shadow on the one below. Now rotate that plane around X axis so it’s upside down. It’s still casting a shadow, but you can’t see it.

ok i see a circle shadow under my camera…but i don’t know where is invisible object that cast this image. I use ngui for a little gui, camra is the camera associated to ngui…and i see this enormous shadow under it. another prolem is that seems there is a sort f shadow poyected near object, so this modify the texture applied on object but this i see in part out of the circle shadow…

make a new material go into the shader and select particle/additive and then tint the color of the material to black and it should make your game object (that you apply this material to) invisible and it should cast shadow since it doesnt affect your renderer :slight_smile: