Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. Shader "Unlit/Dissolve"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. _NoiseTex ("Noise", 2D) = "white" {}
  7. _Dissolve("Dissolve value", Range(0,2)) = 1
  8. }
  9. SubShader
  10. {
  11. Tags { "RenderType"="Transparent" }
  12. ZWrite On
  13. Blend SrcAlpha OneMinusSrcAlpha
  14. LOD 100
  15.  
  16. Pass
  17. {
  18. CGPROGRAM
  19. #pragma vertex vert
  20. #pragma fragment frag
  21. // make fog work
  22. #pragma multi_compile_fog
  23.  
  24. #include "UnityCG.cginc"
  25.  
  26. struct appdata
  27. {
  28. float4 vertex : POSITION;
  29. float2 uv : TEXCOORD0;
  30. };
  31.  
  32. struct v2f
  33. {
  34. float2 uv : TEXCOORD0;
  35. UNITY_FOG_COORDS(1)
  36. float4 projPos : TEXCOORD2;
  37. float4 vertex : SV_POSITION;
  38. };
  39.  
  40. sampler2D _MainTex;
  41.  
  42. sampler2D _NoiseTex;
  43. float4 _MainTex_ST;
  44. float _Dissolve;
  45.  
  46. v2f vert (appdata v)
  47. {
  48. v2f o;
  49. o.vertex = UnityObjectToClipPos(v.vertex);
  50. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  51. UNITY_TRANSFER_FOG(o,o.vertex);
  52. o.projPos = ComputeScreenPos (o.vertex);
  53. return o;
  54. }
  55.  
  56. fixed4 frag (v2f i) : SV_Target
  57. {
  58. // sample the texture
  59. fixed4 col = tex2D(_MainTex, i.uv);
  60. fixed4 noise = tex2D(_NoiseTex, i.projPos);
  61. float dissolve = step(noise.r, _Dissolve);
  62. col = col * dissolve;
  63. col.a = dissolve;
  64. // apply fog
  65. UNITY_APPLY_FOG(i.fogCoord, col);
  66. return col;
  67. }
  68. ENDCG
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement