Dissolve_TexturCoords.shader 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. Shader "Custom/Dissolve_TexturCoords" {
  2. Properties {
  3. _Color ("Main Color", Color) = (1,1,1,1)
  4. _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
  5. _Shininess ("Shininess", Range (0.03, 1)) = 0.078125
  6. _Amount ("Amount", Range (0, 1)) = 0.5
  7. _StartAmount("StartAmount", float) = 0.1
  8. _Illuminate ("Illuminate", Range (0, 1)) = 0.5
  9. _Tile("Tile", float) = 1
  10. _DissColor ("DissColor", Color) = (1,1,1,1)
  11. _ColorAnimate ("ColorAnimate", vector) = (1,1,1,1)
  12. _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
  13. _BumpMap ("Normalmap", 2D) = "bump" {}
  14. _DissolveSrc ("DissolveSrc", 2D) = "white" {}
  15. _DissolveSrcBump ("DissolveSrcBump", 2D) = "white" {}
  16. }
  17. SubShader {
  18. Tags { "RenderType"="Opaque" }
  19. LOD 400
  20. cull off
  21. CGPROGRAM
  22. #pragma target 3.0
  23. #pragma surface surf BlinnPhong addshadow
  24. sampler2D _MainTex;
  25. sampler2D _BumpMap;
  26. sampler2D _DissolveSrc;
  27. sampler2D _DissolveSrcBump;
  28. fixed4 _Color;
  29. half4 _DissColor;
  30. half _Shininess;
  31. half _Amount;
  32. static half3 Color = float3(1,1,1);
  33. half4 _ColorAnimate;
  34. half _Illuminate;
  35. half _Tile;
  36. half _StartAmount;
  37. struct Input {
  38. float2 uv_MainTex;
  39. float2 uv_BumpMap;
  40. float2 uvDissolveSrc;
  41. };
  42. void vert (inout appdata_full v, out Input o) {}
  43. void surf (Input IN, inout SurfaceOutput o) {
  44. fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
  45. o.Albedo = tex.rgb * _Color.rgb;
  46. float ClipTex = tex2D (_DissolveSrc, IN.uv_MainTex/_Tile).r ;
  47. float ClipAmount = ClipTex - _Amount;
  48. float Clip = 0;
  49. float4 DematBump = tex2D (_DissolveSrcBump,IN.uv_MainTex/_Tile);
  50. o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
  51. if (_Amount > 0)
  52. {
  53. if (ClipAmount <0)
  54. {
  55. Clip = 1; //clip(-0.1);
  56. }
  57. else
  58. {
  59. if (ClipAmount < _StartAmount)
  60. {
  61. if (_ColorAnimate.x == 0)
  62. Color.x = _DissColor.x;
  63. else
  64. Color.x = ClipAmount/_StartAmount;
  65. if (_ColorAnimate.y == 0)
  66. Color.y = _DissColor.y;
  67. else
  68. Color.y = ClipAmount/_StartAmount;
  69. if (_ColorAnimate.z == 0)
  70. Color.z = _DissColor.z;
  71. else
  72. Color.z = ClipAmount/_StartAmount;
  73. o.Albedo = (o.Albedo *((Color.x+Color.y+Color.z))* Color*((Color.x+Color.y+Color.z)))/(1 - _Illuminate);
  74. o.Normal = UnpackNormal(tex2D(_DissolveSrcBump, IN.uvDissolveSrc));
  75. }
  76. }
  77. }
  78. if (Clip == 1)
  79. {
  80. clip(-0.1);
  81. }
  82. //////////////////////////////////
  83. //
  84. o.Gloss = tex.a;
  85. o.Alpha = tex.a * _Color.a;
  86. o.Specular = _Shininess;
  87. }
  88. ENDCG
  89. }
  90. FallBack "Specular"
  91. }