Shader "Custom/wMaillageShader" { <<<<<<< HEAD Properties { _MainTex("Texture", 2D) = "white" {} _Color("Color", Color) = (1,1,1,1) _Threshold("Threshold", float) = 0.01 _EdgeColor("Edge color", Color) = (1,0,0,1) _Glossiness("Smoothness", Range(0,1)) = 0.5 _Metallic("Metallic", Range(0,1)) = 0.0 } SubShader { Cull Off ZWrite Off ZTest Always Tags { "RenderType" = "Opaque" } Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; }; struct v2f { float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; }; sampler2D _CameraDepthNormalsTexture; float4 _MainTex_ST; v2f vert(appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = TRANSFORM_TEX(v.uv, _MainTex); return o; } sampler2D _MainTex; float4 _MainTex_TexelSize; float _Threshold; fixed4 _EdgeColor; float4 GetPixelValue(in float2 uv) { half3 normal; float depth; DecodeDepthNormal(tex2D(_CameraDepthNormalsTexture, uv), depth, normal); return fixed4(normal, depth); } fixed4 frag(v2f i) : SV_Target { fixed4 col = tex2D(_MainTex, i.uv); fixed4 orValue = GetPixelValue(i.uv); float2 offsets[8] = { float2(-1, -1), float2(-1, 0), float2(-1, 1), float2(0, -1), float2(0, 1), float2(1, -1), float2(1, 0), float2(1, 1) }; fixed4 sampledValue = fixed4(0,0,0,0); for (int j = 0; j < 8; j++) { sampledValue += GetPixelValue(i.uv + offsets[j] * _MainTex_TexelSize.xy); } sampledValue /= 8; return lerp(col, _EdgeColor, step(_Threshold, length(orValue - sampledValue))); } ENDCG } } ======= Properties { _InnerColor("Inner Color", Color) = (0.0, 0.0, 0.0, 0.5) _RimColor("Rim Color", Color) = (1.0,1.0,1.0,0.5) _RimPower("Rim Power", Range(0.5,8.0)) = 2.47 } SubShader { Tags { "Queue" = "Transparent" } Cull Off ZWrite Off ZTest Less //Blend based on output Alpha, not color value Blend One OneMinusSrcAlpha CGPROGRAM #pragma surface surf Lambert alpha:fade struct Input { float3 viewDir; }; float4 _InnerColor; float4 _RimColor; float _RimPower; void surf(Input IN, inout SurfaceOutput o) { half rim = 1.0 - saturate(dot(normalize(IN.viewDir), o.Normal)); rim = pow(rim, _RimPower); //Shift inner color to rim color by rim value adjusted by _InnerColor transparency to reduce its effect //on semi-transparent part of rim color the more transparent inner color becomes. o.Emission = lerp(_InnerColor.rgb, _RimColor.rgb, saturate(rim + (1 - _InnerColor.a) - (1 - _RimColor.a))); o.Alpha = lerp(_InnerColor.a, _RimColor.a, rim); } ENDCG } Fallback "Diffuse" >>>>>>> shader }