123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- 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
- }
|