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 Larry-W · Mar 02, 2015 at 06:43 AM · c#shadermeshgraphicsalpha

How can I make a part of a mesh to be invisible - ie: see through parts of walls...

I have a 3rd person camera that has it's .forward always pointing towards a specific object.

Occasionally this object finds itself behind other objects/meshes (like walls for instance).

I have a script that checks if this main object is visible by casting a ray from the cam's forward/center to this object's position.

I would like to be able to make a "hole" in the any mesh hit by the ray that is not the main target object described above; I would like this hole to originate from the rayHit.point's position.

I'm thinking the hole can only be an illusion, perhaps a superimposed alpha mask texture that will hide a circular subsection of the wall's alpha.... (like a square image, all transparent, with a black circle in its center).

How can I do this in script? Apply an "layer mask" to a material...?

Or perhaps another way of accomplishing what I am describing...?

Thanks!

Comment
Add comment · Show 3
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 AlwaysSunny · Mar 02, 2015 at 08:03 AM 0
Share

The approach you're describing requires you to render the scene with multiple cameras and use render textures to mask at least one camera's final output with a screen-space alpha mask centered on your VIP. This requires Unity Pro, and, frankly, more know-how than I currently possess.

It's also possible that you could use a shader to accomplish this - a shader which fades the alpha of any pixel in a certain screen-space region (centered on your VIP). For this to work as intended, any object you ever want to "see through" in this fashion must use a shader with this feature. Yet another task I lack the knowledge to recommend.

The render-texture method is definitely preferable, but the shader method shouldn't require Unity Pro.

I'm sure I've seen a blog post or something about doing this. Try hunting for examples where this has been done for better info.

avatar image Cherno · Mar 02, 2015 at 11:28 AM 0
Share

^Agreed. Search for "X-Ray Shader" or something like that.

X-Ray / CutOut Shader with mouse

Edit: Also:

Painting holes with Shader 2.0

avatar image Larry-W · Mar 03, 2015 at 08:04 PM 0
Share

Will have a go at those two links you posted, looks promising! thanks.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by wesleywh · Mar 02, 2015 at 05:01 PM

I know this isn't quite the answer your looking for but you could add a texture that is see through to the object when it's hit with that ray. Just make some texture with 50% opacity and import that texture to unity and use that texture when it is hit with the ray.

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 Larry-W · Mar 03, 2015 at 08:03 PM 0
Share

That's actually how I currently have it setup. A script casts a ray every frame from cam center, along cam forward, and sends a message to every non-main object encountered to "disappear", which triggers a change of shader (to translucent + shadow) and gradually changes alpha over time. This configuration requires a very specific hierarchy setup and drastically lengthens the level-making process... But ya, great idea :) thanks.

avatar image
0

Answer by westingtyler · Mar 28, 2020 at 06:07 AM

I had similar troubles with my third person camera clipping through walls and hiding my hero. making the walls invisible or transparent or having holes is one way, but for my needs I solved the problem by switching my camera system to use Unity's Cinemachine free look camera (as of 2020 they have in beta a Third Person Follow camera, which I have not yet checked out) and I blend this with my Cinemachine virtual camera for first-person mode.

But the solution is adding a Cinemachine Collider script, which is built into cinemachine, onto my free look camera. Setting it up to ignore the player tag but collide against other things, and pull the camera forward, means this automatically avoids walls. Tweak to your liking.

It's great that problems like these are so instantly solved by the new additions to the Unity engine. my previous setup was obnoxious by comparison to Cinemachine.

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

6 People are following this question.

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

Related Questions

Dymanic Mesh Hiding 2 Answers

Geometry shader output to mesh in Unity 4 0 Answers

Shader - Hide self overlapping mesh 1 Answer

Altering color / alpha on a Game Object 1 Answer

Cube botttom transparent with shader? 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