1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| Shader "JaffHan/Wireframe" { Properties { _Color("Color",Color)=(1.0,1.0,1.0,1.0) _EdgeColor("Edge Color",Color)=(1.0,1.0,1.0,1.0) _Width("Width",Range(0,1))=0.2 } SubShader {
Pass { CGPROGRAM
struct a2v { half4 uv : TEXCOORD0 ; half4 vertex : POSITION ; UNITY_VERTEX_INPUT_INSTANCE_ID //Insert };
struct v2f{ half4 pos : SV_POSITION ; half4 uv : TEXCOORD0 ; UNITY_VERTEX_OUTPUT_STEREO //Insert }; fixed4 _Color; fixed4 _EdgeColor; float _Width; v2f vert(a2v v) { v2f o; UNITY_SETUP_INSTANCE_ID(v); //Insert UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert o.uv = v.uv; o.pos=UnityObjectToClipPos(v.vertex); return o; }
fixed4 frag(v2f i) : COLOR { fixed4 col; float lx = step(_Width, i.uv.x); float ly = step(_Width, i.uv.y); float hx = step(i.uv.x, 1.0 - _Width); float hy = step(i.uv.y, 1.0 - _Width); col = lerp(_EdgeColor, _Color, lx*ly*hx*hy); return col; } ENDCG } } FallBack "Diffuse" }
|