Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 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
1
Question by Illogical-Ironic · Aug 26, 2011 at 05:45 PM · shadowmultipleprojectorblob

Blob shadow going through multiple objects.

Since i am using Basic Unity, I'm limited to use the Blob Shadow Projector. It has worked fine for me until now, because of the following:

In one of the scenes, i have a few platforms, which are a few units above other objects, including a Terrain.

My problem is, the projector casts the blob shadow on any surfaces within the range of the projector. I tried to use a Spotlight instead, but unsuccessfully, because black is 100% transparent.

How do i prevent the blob shadow from being projected on multiple surfaces without sacrificing projection on slopes?

The blob shadow was placed as a component on a Ball-shaped player. Edit: Here's a screenshot:

http://i55.tinypic.com/73jxo5.png

Comment
Add comment · Show 1
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 Mizuho · Jun 25, 2012 at 04:47 AM 0
Share

If you're not too picky about a few dollars, there's the additional option of: http://u3d.as/content/gustav-olsson/shadow-volumes-toolkit/2gF.

5 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by dai1741 · Sep 29, 2011 at 07:13 AM

I think there is no way to cast shadow only on the first hit object for free.

You can simulate it by changing the projector's range dynamically, however, this can cause awkward effects in many cases.
If that's ok for you, write a script like below and attach it to the parent GameObject of Blob Shadow Projector.

ShadowClipper.js

 var shadowProjector : Projector; // the shadow projector
 var shadowDistanceTolerance : float = 0.5; // positive number used to cast shadow on terrains correctly
 
 private var origNearClipPlane : float;
 private var origFarClipPlane : float;
 
 function Start() {
     if(!shadowProjector) shadowProjector = transform.GetComponentInChildren.<Projector>();
     origNearClipPlane = shadowProjector.nearClipPlane;
     origFarClipPlane = shadowProjector.farClipPlane;
 }
 
 function Update() {
     var ray = new Ray(shadowProjector.transform.position
             + shadowProjector.transform.forward.normalized * origNearClipPlane,
             shadowProjector.transform.forward);
 
     var hit : RaycastHit;
     if (Physics.Raycast (ray, hit, origFarClipPlane - origNearClipPlane,
             ~shadowProjector.ignoreLayers)) {
         var dist = hit.distance + origNearClipPlane;
         shadowProjector.nearClipPlane = Mathf.Max(dist - shadowDistanceTolerance, 0);
         shadowProjector.farClipPlane = dist + shadowDistanceTolerance;
         //Debug.Log("Ray hit at: " + hit.point + ", distance: " + dist);
     }
 }
Comment
Add comment · Show 1 · 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 luniac · Jun 25, 2012 at 03:54 AM 0
Share

hey this is great code, i modified it a little and post for the heck of it

avatar image
-1

Answer by lunisolar · Aug 31, 2011 at 03:06 PM

I haven't been able to try unity in depth yet, but I know photoshop. not sure if this will work, but if you were doing something like that in PS you would create 2 copies of the shadow and cut away the part you dont want showing through the platform.

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
avatar image
0

Answer by Nerull22 · Aug 31, 2011 at 01:42 AM

All right, not sure how much of an answer this is, as I'm not 100% for what you're using. But if you're using a light, I would look into culling masks. You should be able to select what type of object it will project onto. Hope this helps.

Comment
Add comment · Show 1 · 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 Illogical-Ironic · Aug 31, 2011 at 02:54 PM 0
Share

Tried that, but it doesn't works in my case. The platforms and the terrain are in the same layer since i need the shadow on both of them. What i really want is the blob shadow showing on platforms, without also going through them.

avatar image
0

Answer by luniac · Jun 25, 2012 at 03:57 AM

 #pragma strict
 
 var shadowProjector : Projector; // the shadow projector
 var shadowDistanceTolerance : float = 0.5; // positive number used to cast shadow on terrains correctly
 
 private var hit : RaycastHit;
 private var dist : float;            
 private var origNearClipPlane : float;
 private var origFarClipPlane : float;
 private var ray : Ray;
 
 function Start() {
     if(!shadowProjector) shadowProjector = transform.GetComponentInChildren.<Projector>();
     origNearClipPlane = shadowProjector.nearClipPlane;
     origFarClipPlane = shadowProjector.farClipPlane;
     
 }
 
 function Update() {
     ray = new Ray(shadowProjector.transform.position
             + shadowProjector.transform.forward.normalized * origNearClipPlane,
             shadowProjector.transform.forward);
 
     
     if (Physics.Raycast (ray, hit, origFarClipPlane - origNearClipPlane, ~shadowProjector.ignoreLayers)) 
     {
         dist = hit.distance + origNearClipPlane;
         Debug.Log(dist);
         
         //shadowProjector.nearClipPlane = Mathf.Max(dist - shadowDistanceTolerance, 12);
         
         //dist = 12 for large ball
         if(dist >= 12)
         shadowProjector.nearClipPlane = 15;//value higher than 12
         else
         shadowProjector.nearClipPlane = origNearClipPlane;
         
         shadowProjector.farClipPlane = dist + shadowDistanceTolerance;
         //Debug.Log("Ray hit at: " + hit.point + ", distance: " + dist);
     }
 }
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 luniac · Jun 25, 2012 at 03:59 AM 0
Share

includes some values specific to my game, but basically the shadow fades in once again ins$$anonymous$$d of being at almost constant strength all the time. Only problem is if you have lots of edges over each other then the shadow will be projected on all of em.. albeit at different strength based on distance, so it sorta is realistic.. as far as blob shadows go...

just use dist >= "your farthest distance value where object is touching surface point blank"

avatar image luniac · Jun 25, 2012 at 04:11 AM 0
Share

actually with more testing i see that theres an instant if object is in air above surface where shadow disappears... perhaps theres way to fix that but im tired of blob shadows ....

avatar image
0

Answer by Xorse · Oct 30, 2012 at 06:50 PM

Hi I'm new to Unity but have had similar problems, take a look at this: http://answers.unity3d.com/questions/8753/how-to-prevent-blob-shadow-to-cast-on-my-player.html This may help if you can dynamically change which layers it should ignore. Let me know if this works as this may be useful when I get further with my Unity project. Thanks

Maybe if you can use a ray cast to find the object directly beneath you and enable this in the layer while disabling the last object the ray cast found?

Found this as well: http://answers.unity3d.com/questions/168084/change-layer-of-child.html Hope this helps!

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

8 People are following this question.

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

Related Questions

Blob shadow with a pseudo realtime effect 0 Answers

Shadow Projector Component not pointed down 1 Answer

Blob Shadows 1 Answer

Has anyone noticed that Unity's default projectors don't display correctly in Internet Explorer? 0 Answers

How do you make blob shadow ignore sphere? 1 Answer


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