Advertisement
Guest User

Untitled

a guest
Jan 16th, 2023
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/DissolveWithNoise" {
  2.     Properties {
  3.         _MainTex ("Sprite Texture", 2D) = "white" {}
  4.         _NoiseTex ("Noise Texture", 2D) = "white" {}
  5.         _DissolveAmount ("Dissolve Amount", Range(0, 1)) = 0.5
  6.         _Threshold ("Threshold", Range(0, 1)) = 0.5
  7.     }
  8.  
  9.     SubShader {
  10.         Tags {"Queue"="Transparent" "RenderType"="Transparent"}
  11.         LOD 100
  12.  
  13.         Pass {
  14.             CGPROGRAM
  15.             #pragma vertex vert
  16.             #pragma fragment frag
  17.             #include "UnityCG.cginc"
  18.  
  19.             struct appdata {
  20.                 float4 vertex : POSITION;
  21.                 float2 uv : TEXCOORD0;
  22.             };
  23.  
  24.             struct v2f {
  25.                 float2 uv : TEXCOORD0;
  26.                 float4 vertex : SV_POSITION;
  27.             };
  28.  
  29.             sampler2D _MainTex;
  30.             sampler2D _NoiseTex;
  31.             float _DissolveAmount;
  32.             float _Threshold;
  33.  
  34.             v2f vert (appdata v) {
  35.                 v2f o;
  36.                 o.vertex = UnityObjectToClipPos(v.vertex);
  37.                 o.uv = v.uv;
  38.                 return o;
  39.             }
  40.  
  41.             fixed4 frag (v2f i) : SV_Target {
  42.                 fixed4 col = tex2D(_MainTex, i.uv);
  43.                 fixed4 noise = tex2D(_NoiseTex, i.uv);
  44.                 col.a = col.a * step(noise.r, _Threshold) * _DissolveAmount;
  45.                 return col;
  46.             }
  47.             ENDCG
  48.         }
  49.     }
  50.     FallBack "Diffuse"
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement