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
1
Question by Diggler · Aug 06, 2013 at 12:51 PM · playershaderstransparencywall

Make wall partially transparent when player is behind it

Hi guys, I'm trying to create a specific shader for my game. It's an isometric game, and any time the player is obscured behind a wall I want to be able to "cut out" a circle in the geometry around him so that he can be seen at all times. A perfect example can be seen in this video from Fallout 1, at exactly 8:36;

http://www.youtube.com/watch?v=tlxRCi9OvZo

I particularly like how the circle has soft edges and really want to emulate that specifically.

Now I've actually made some decent progress with this, but I'm still not an expert with shaders so I defo still need some advice on getting it properly implemented. Thanks to other forum posts and tutorials I've experimented with the "depth mask" here; ( http://wiki.unity3d.com/index.php?title=DepthMask ) and managed to "cut out" a solid circle in my walls which exposes my character, by simply placing a "mask" object in front of him at all times. However it cuts out ALL walls including those deeper into the scene behind him, not just the front most, and it also doesn't have the smooth edges I'm looking for either. Has potential, but I put it on old.

I then found an old thread on these forums ( http://forum.unity3d.com/threads/35808-Projecting-a-hole ) about someone using a projector to "paint" transparency over objects as needed, with the projector essentially cutting through anything it shines on. This looks really nice, works well, and with the right shaped round alpha, even has nice soft edges. The down side is that the example(s) in the thread only work on very, very simple materials. As in, solid coloured objects and nothing more. I need fully materialed objects with their own textures, lighting, possibly even normals, etc, that I can still project a hole whenever needed.

Would really appreciate any tips or advice, or even solutions if you guys have any. I know it's quite a tall order, but it would really make my game shine. I could possibly provide a (very) small payment if anyone's willing to write the whole thing from scratch if it looks as good as in Fallout.

Comment
Add comment
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

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by ivan2532 · Aug 07, 2013 at 02:49 PM

Hello Diggler, you should create two materials. Here is the code:

 var transparentMaterial : Material;
 private var myMaterial : Material;
 
 function Awake()
 {
     myMaterial = gameObject.renderer.material;
 }
 
 function Update()
 {
     if(<here is the code to check if he is behind the wall>)
     {
         gameObject.renderer.material = transparentMaterial;
     }
     else
     {
         gameObject.renderer.material = myMaterial;
     }
 }

Tell me if it works, and tell me if it doesn't!

Ivan Božović

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 tw1st3d · Aug 07, 2013 at 02:56 PM 0
Share

I would personally define the two textures in the inspector, then assign it on Awake() ins$$anonymous$$d of assigning my$$anonymous$$aterial to the current texture. Other than that, good answer.

avatar image ivan2532 · Aug 07, 2013 at 03:15 PM 0
Share

Thank you! :D

avatar image
1

Answer by bear1998 · Feb 25, 2019 at 03:24 PM

hey know this is an old post but im stuck on this also and cant really work out what exactly I need to be doing to achieve desiered effects

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 Wopsie · May 31, 2020 at 09:33 PM 0
Share

Something that might come in useful for your case is the stencil buffer. I think the stencil buffer was not accessible to Unity users at the time of this thread's creation, however now it can be utilized in shader code to basically get such a cutout effect. Im currently working on a similar effect myself, though its not at all what its supposed to be yet.

Example

avatar image
0

Answer by nwsx · Mar 27, 2014 at 05:03 PM

http://steamcommunity.com/sharedfiles/filedetails/?id=240845770 check this out this unity game has fallout style wall holes

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 CatsPawGames · Nov 18, 2014 at 04:04 PM

You can use See-Through System to achieve that. It's shader-independent, so you don't need to change your materials. It's avaliable on asset store: http://www.assetstore.unity3d.com/#/content/24707

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

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

Related Questions

how to make a player die on collision 2 Answers

Prefab's High poly mesh VS lower poly transparency cutout 2 Answers

Shader Constants - Lighting Params require Queue=Geometry? 1 Answer

I have transparent shader, but after quad with it material all objects with not default sorting layer are unvisible 0 Answers

PBR shader is too transparent 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