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
0
Question by StigC · Oct 17, 2017 at 10:08 AM · 2dshaderhideholesee through

See-through hole/hide away walls in a 2D environment (via shader)?

Hi there,

While searching for an answer to my own question, I ran into this post from 2013. I can't for the love of Jessy get his solution working, nor find similar answers online.

Anyone who can help?

alt text

I've made a material with the shader, then added that material to a spriterenderer in my world. That sprite is supposed to be following the player around, hoping to see through walls when he walks by them. In the case of the picture above, I've placed the sprite in front of a wall, hoping it'd hide the wall away and reveal the floor.

Jessy's Shader:

  Shader "Hole Thing" {
  
  Properties {
      _Center ("Hole Center", Vector) = (.5, .5, 0 , 0)
      _Radius ("Hole Radius", Float) = .25
      _Shape ("Hole Shape", Float) = .25
      _MainTex ("Main Texture", 2D) = ""
  }
  
  SubShader {
      Tags {"Queue" = "Transparent"}
      Blend SrcAlpha OneMinusSrcAlpha
      Pass {
          CGPROGRAM
          struct appdata {
              float4 position : POSITION;
              half2 texCoord : TEXCOORD;
          }; 
          
          struct v2f {
              float4 position_clip : SV_POSITION;
              half2 position_uv : TEXCOORD;
          };
          
          #pragma vertex vert
          uniform half4 _MainTex_ST;
          v2f vert(appdata i) {
              v2f o;
              o.position_clip = mul(UNITY_MATRIX_MVP, i.position);
              o.position_uv = _MainTex_ST.xy * i.texCoord + _MainTex_ST.zw;
              return o;
          }
          
          #pragma fragment frag
          uniform sampler2D _MainTex;
          uniform half2 _Center;
          half _Radius, _Shape;
          fixed4 frag(v2f i) : COLOR {        
              fixed4 fragColor = tex2D(_MainTex, i.position_uv);
              half hole = min(distance(i.position_uv, _Center) / _Radius, 1.);
              fragColor.a *= pow(hole, _Shape);
              return fragColor;
          }
          ENDCG
      }
  }
  
  }

How do you set this kinda thing up correctly? Any help would be appreciated!

Thanks

help.png (265.8 kB)
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

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

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

Related Questions

See-through hole via shaders on a 2D plane 2 Answers

Cutting hole from player character to camera through multiple sprites with edge blending 0 Answers

Sprite texture incorrect 0 Answers

Any way to access light level of a pixel in a sprite via the shader graph? [URP],Can I access the light level in shader graph for spot light 2D? [URP] 1 Answer

Age of Empire Mini Map 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