Dissolve_WorldCoords.shader 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. Shader "Custom/Dissolve_WorldCoords" {
  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. float3 worldPos;
  42. };
  43. void vert (inout appdata_full v, out Input o) {}
  44. void surf (Input IN, inout SurfaceOutput o) {
  45. fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
  46. o.Albedo = tex.rgb * _Color.rgb;
  47. float ClipTex = tex2D (_DissolveSrc, float2(IN.worldPos.x,IN.worldPos.y)/_Tile).r * tex2D (_DissolveSrc, float2(IN.worldPos.y,IN.worldPos.z)/_Tile).g;
  48. float ClipAmount = ClipTex - _Amount;
  49. float Clip = 0;
  50. float4 DematBump = tex2D (_DissolveSrcBump, float2(IN.worldPos.x,IN.worldPos.y)/_Tile) * tex2D (_DissolveSrcBump, float2(IN.worldPos.y,IN.worldPos.z)/_Tile);
  51. o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
  52. if (_Amount > 0)
  53. {
  54. if (ClipAmount <0)
  55. {
  56. Clip = 1; //clip(-0.1);
  57. }
  58. else
  59. {
  60. if (ClipAmount < _StartAmount)
  61. {
  62. if (_ColorAnimate.x == 0)
  63. Color.x = _DissColor.x;
  64. else
  65. Color.x = ClipAmount/_StartAmount;
  66. if (_ColorAnimate.y == 0)
  67. Color.y = _DissColor.y;
  68. else
  69. Color.y = ClipAmount/_StartAmount;
  70. if (_ColorAnimate.z == 0)
  71. Color.z = _DissColor.z;
  72. else
  73. Color.z = ClipAmount/_StartAmount;
  74. o.Albedo = (o.Albedo *((Color.x+Color.y+Color.z))* Color*((Color.x+Color.y+Color.z)))/(1 - _Illuminate);
  75. o.Normal = UnpackNormal(tex2D(_DissolveSrcBump, IN.uvDissolveSrc));
  76. }
  77. }
  78. }
  79. if (Clip == 1)
  80. {
  81. clip(-0.1);
  82. }
  83. //////////////////////////////////
  84. //
  85. o.Gloss = tex.a;
  86. o.Alpha = tex.a * _Color.a;
  87. o.Specular = _Shininess;
  88. }
  89. ENDCG
  90. }
  91. FallBack "Specular"
  92. }