Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by yetstay · Mar 11, 2012 at 03:29 AM · camerashaderraycasttoon shadertransparancy

Ojbect with Unity's default Toon Light/outlined Shader drawing black when seen from inside?

Hello all, Unity's got a great community here and hope I could find some help from you. I've got a C# script that turns anything that comes between the camera and the player transparent. I have a list of objects and I raycast from the camera to the player to see if anything comes in sight, and if something does then turn it transparent by saving the mat, colour and the shader and change it with Transparent shader/mat/etc then save it in the list. When the object is "out of sight" by raycast test, it restores the original settings then pops out of the list. It's a bit different than what's suggested here: http://answers.unity3d.com/questions/44815/make-object-transparent-when-between-camera-and-pl.html but it worked and it's basically the same idea.

Well, it worked well when I was using any other shaders than the toon shader. This is where I am having a problem: I am using single sided objects and when my camera's placed inside the object, the object isn't drawn with other shaders so I didn't have to worry about the object. With the toon shaders however, when the camera's inside the object, the object is rendered black.

The object is still going transparent if the object is placed between the camera and the player, but I just have no idea why the backside of the object is rendered black. I tried to use a double sided object and when camera's placed inside the object it was actually rendering the backside of the object so I didn't think the Physics.raycast is picking up the object from inside. I came across this: http://forum.unity3d.com/threads/43621-Raycast-from-inside-Collider-is-inconsistent but I am still not sure about it.

I also tried disabling Culling/enabling different culling sides(front/back) in the toon shaders themselves but that basically messed up the scene... Currently I am putting the objects on a layer that pushes the camera away so the camera doesn't go through the object but then again there's no need for the original script since camera's always pushed by the object when it comes in sight.

Does anyone know what's happening here? Also is there any way to solve this problem and make the object transparent when the camera's placed inside of the object while the shader's rendering the backside for no apparent reason? Is this a shader specific problem at all? I am thinking of putting a collider around the camera and see if it's colliding with any object with OnCollisionEnter/OnTriggerEnter calls and if it is then make the object transparent, but that will make walls I have (boundaries of game world) transparent as well unless I use tags/layers and that's a lot of work too...Any help would be appreciated, thank you!

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 yetstay · Mar 28, 2012 at 03:51 AM 0
Share

It seems that the "outline" part of toon shader is rendering things black from even inside of the object. For now I've implemented what I described in the last paragragh and it works so I will just leave it at that but I'd really love to know if someone comes up with a shader solution :)

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Rotate a ray to camera direction, in a CG shader 1 Answer

Several questions about OnRenderObject and Camera projection matrix use. 0 Answers

Dividng clip space by "w" warps the output? 1 Answer

How can I change this script? 0 Answers

raycast not doing good 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