Newer
Older
Dreamsturbia-Project-IADE-Unity3D / Assets / Shaders / DissolveShader.shader
  1. Shader "MyShaders/Dissolve"{
  2. Properties{
  3. _Color("Color", Color) = (1,1,1,1)
  4. _MainTex("Texture", 2D) = "white"{}
  5. _NoiseTex("Noise Texture", 2D) = "white"{}
  6. _DissolveThreshold("Dissolve Threshold", Range(0, 1)) = 0.5
  7. }
  8. SubShader{
  9. Pass{
  10. HLSLPROGRAM
  11. #pragma vertex MyVertexProgram
  12. #pragma fragment MyFragmentProgram
  13. #include "UnityCG.cginc"
  14. struct VertexData {
  15. float4 position : POSITION;
  16. float2 uv : TEXCOORD0;
  17. };
  18. struct VertexToFragment {
  19. float4 position : SV_POSITION;
  20. float2 uv : TEXCOORD0;
  21. float2 uvNoise : TEXCOORD1;
  22. };
  23. float4 _Color;
  24. sampler2D _MainTex, _NoiseTex;
  25. float4 _MainTex_ST, _NoiseTex_ST;
  26. float _DissolveThreshold;
  27. VertexToFragment MyVertexProgram(VertexData vertex)
  28. {
  29. VertexToFragment v2f;
  30. v2f.position = UnityObjectToClipPos(vertex.position);
  31. v2f.uv = vertex.uv * _MainTex_ST.xy + _MainTex_ST.zw;
  32. v2f.uvNoise = vertex.uv * _NoiseTex_ST.xy + _NoiseTex_ST.zw;
  33. return v2f;
  34. }
  35. float4 MyFragmentProgram(VertexToFragment v2f) : SV_TARGET
  36. {
  37. float4 color = tex2D(_MainTex, v2f.uv);
  38. float4 noise = tex2D(_NoiseTex, v2f.uvNoise);
  39. clip(noise.rgb - _DissolveThreshold);
  40. return color * _Color;
  41. }
  42. ENDHLSL
  43. }
  44. }
  45. }