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.

Certainly not, the shadow casting/receiving are inside the renderer. Turning the renderer off obviously makes the object unable to be rendered meaning it isn't included in the shadow calculations. I am also talking about realtime shadows, of course i am using Unity Pro.

4 Replies

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" )

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.

The word "normals" might be a bit confusing here, since in Unity, normals are used exclusively for lighting. The thing determining whether a face is front- or backfacing is exclusively the point order of the triangles in the mesh, and it can't even be changed with negatice scaling of the transform.

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 :)

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..