Quantcast
Channel: Questions in topic: "see through"
Viewing all articles
Browse latest Browse all 71

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

$
0
0
Hi there, While searching for an answer to my own question, [I ran into this post from 2013][1]. I can't for the love of Jessy get his solution working, nor find similar answers online. Anyone who can help? ![alt text][2] 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 [1]: http://answers.unity3d.com/questions/449034/see-through-hole-via-shaders-on-a-2d-plane.html [2]: /storage/temp/103905-help.png

Viewing all articles
Browse latest Browse all 71

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>