123456789101112131415161718192021222324252627282930313233343536 |
- Shader "Custom/wMaillageShader"
- {
- 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"
- }
|