InnerGlow.shader 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. Shader "Custom/InnerGlow" {
  2. Properties{
  3. _MainTex("Diffuse(RGB) Spec(A)", 2D) = "white" {}
  4. _BumpMap("Bumpmap", 2D) = "bump" {}
  5. _RimColor("Rim Color", Color) = (0.26,0.19,0.16,0.0)
  6. _RimPower("Rim Power", Range(0.5,8.0)) = 3.0
  7. _SpecColor("Specular Color", Color) = (0.5,0.5,0.5,1)
  8. _Shininess("Shininess", Range(0.01, 1)) = 0.078125
  9. }
  10. SubShader{
  11. Tags{ "RenderType" = "Opaque" }
  12. CGPROGRAM
  13. #pragma surface surf NoLighting
  14. float _Shininess;
  15. half4 LightingSimpleSpecular(SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) {
  16. half3 h = normalize(lightDir + viewDir);
  17. half diff = max(0, dot(s.Normal, lightDir));
  18. float nh = max(0, dot(s.Normal, h));
  19. float spec = pow(nh, 48.0);
  20. half4 c;
  21. c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec * s.Alpha * _Shininess * _SpecColor) * (atten * 2);
  22. c.a = s.Alpha;
  23. return c;
  24. }
  25. struct Input {
  26. float2 uv_MainTex;
  27. float2 uv_BumpMap;
  28. float3 viewDir;
  29. };
  30. sampler2D _MainTex;
  31. sampler2D _BumpMap;
  32. float4 _RimColor;
  33. float _RimPower;
  34. void surf(Input IN, inout SurfaceOutput o) {
  35. o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb;
  36. o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
  37. half rim = 1.0 - saturate(dot(normalize(IN.viewDir), o.Normal));
  38. o.Emission = _RimColor.rgb * pow(rim, _RimPower);
  39. o.Alpha = tex2D(_MainTex, IN.uv_MainTex).a;
  40. }
  41. fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, fixed atten)
  42. {
  43. fixed4 c;
  44. c.rgb = s.Albedo;
  45. c.a = s.Alpha;
  46. return c;
  47. }
  48. ENDCG
  49. }
  50. Fallback "Diffuse"
  51. }