Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
11
Question by yeoldesnake 1 · Jun 18, 2012 at 02:28 PM · shaderobjectshadowinvisiblecast

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.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Exeed · Jun 18, 2012 at 05:25 PM 0
Share

u can try Render Is False Then If u Have The Pro Unity $$anonymous$$ake The Shadow True In the Inspector of the direction Light i hope that helped

avatar image yeoldesnake 1 · Jun 18, 2012 at 07:19 PM 0
Share

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

· Add your reply
  • Sort: 
avatar image
52
Best Answer

Answer by manutoo · Sep 24, 2012 at 09:15 AM

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"
 {
     Subshader
     {
         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 :

http://d.pr/i/nt33

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

Comment
Add comment · Show 14 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image moinchdog · Oct 26, 2012 at 09:45 PM 0
Share

wow thanks worked amazingly!!

avatar image Brenden-Frank · Dec 06, 2012 at 06:07 PM 0
Share

You deserve a a huge thumbs up. Thank you

avatar image alexfeature · Jul 06, 2013 at 09:55 PM 0
Share

Totally awesome!

avatar image leika · Oct 20, 2013 at 09:29 PM 0
Share

I was opening the wrong one. Got it working thanks!

avatar image CoastersPaul · Apr 18, 2015 at 01:21 PM 1
Share

VertexLit/SHADOWCOLLECTOR doesn't seem to work anymore, turning my plane fuchsia. Once that was removed, it casted shadows, but it also blocked shadows. But a bit of tinkering and this works well with Unity 5:

Shader "Custom/InvisibleShadowCaster" { SubShader { Tags { "Queue"="Transparent" "RenderType"="Transparent" "IgnoreProjector"="True"} UsePass "VertexLit/SHADOWCASTER" } FallBack off }

Show more comments
avatar image
1

Answer by DaveA · Jun 18, 2012 at 07:36 PM

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.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Wolfram · Jun 18, 2012 at 08:12 PM 0
Share

The word "normals" might be a bit confusing here, since in Unity, normals are used exclusively for lighting. The thing deter$$anonymous$$ing 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.

avatar image yeoldesnake 1 · Jun 18, 2012 at 11:19 PM 0
Share

I seem to have solved my current issue with something similar, i would still like to know if there is a shader based solution to it however.

avatar image DaveA · Jun 27, 2012 at 03:46 AM 0
Share

Wolfram - I stand corrected, thank you

avatar image
-2

Answer by DeadBug · Jun 18, 2012 at 07:39 PM

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Wolfram · Jun 18, 2012 at 08:13 PM 0
Share

Particle/Additive as well as any Trnasparent shaders don't cast realtime shadows (at least not with Directional Lights and Forward Rendering).

avatar image yeoldesnake 1 · Jun 18, 2012 at 11:18 PM 0
Share

I am pretty sure Particle/Additive does not cast realtime shadows in deferred rendering either.

avatar image
0

Answer by gamer2300 · Jun 11, 2013 at 09:37 PM

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Semi-Transparent Shader that casts and receives shadows 0 Answers

How can I make a translucent object cast a shadow 1 Answer

Semitransparent object that cast shadow 0 Answers

Seperate Shadow Strengths from different objects? 0 Answers

Fading shadows in / out along with material. 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges