[Shder]物体溶解效果

<1>效果图

       

<2>源码:剔除像素 融合就看随机值的大小啦 越靠近0 融合红色 黄色

      

Shader "Legacy Shaders/Transparent/Diffuse" {
Properties{
_Color("Main Color", Color) = (1,1,1,1)
_AddCol("Add Color",Color)=(1,0,0,1)
_AddColY("_AddColY",Color)=(1,1,0,1)
_MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
_NoiseTex("mmp",2D) = "white" {}
_Speed("速度",Range(0.1,2)) = 0.1
}

SubShader{
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
LOD 200

CGPROGRAM
#pragma surface surf Lambert alpha:fade

sampler2D _MainTex;
sampler2D _NoiseTex;
fixed4 _Color;
float _Speed;
fixed4 _AddCol;
fixed4 _AddColY;

struct Input {
float2 uv_MainTex;
};

void surf(Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
fixed r = tex2D(_NoiseTex, IN.uv_MainTex).r;
r -= _Time.x*_Speed;

o.Albedo = c.rgb;

//融合颜色
if (r<0.1)
o.Albedo = c.rgb*_AddColY;

if(r<0.04)
o.Albedo = c.rgb*_AddCol;


//剔除
if (r<0)
clip(r);

o.Alpha = c.a;
}
ENDCG
}

Fallback "Legacy Shaders/Transparent/VertexLit"
}

原文地址:https://www.cnblogs.com/cocotang/p/7412667.html