Unity Shader dissolve effect

renderings

According to the noise map, go to clip

Clip explanation: clip(-0.1); //If it is less than 0, it will be clipped if(value < 0) { discard }

Core code:

fixed4 frag (v2f i) : SV_Target  
{  
    fixed4 col = tex2D(_MainTex, i.texcoord);  
    float ClipTex = tex2D (_NoiseTex, i.texcoord/_Tile).r;  
    float ClipAmount = ClipTex - _Amount;   

    if(_Amount > 0)  
    {  
        if(ClipAmount < 0)  
        {  
            clip(-0.1);   //小于0才会被clip掉 if(value < 0) { discard }
        }  
        else
        {  
            if(ClipAmount < _DissSize)   
            {  
                float4 finalColor=lerp(_DissColor,_AddColor,ClipAmount/_DissSize)*2;  
                col = col * finalColor;  
            }  
        }  
    }  
    UNITY_OPAQUE_ALPHA(col.a);  
    return col;  
}  

sample download

Guess you like

Origin blog.csdn.net/st75033562/article/details/129444005