unity shader 幽灵材质

先上图:
unity shader 幽灵材质_第1张图片
上shader

Shader "test_Ghost"
{
	Properties
	{
		_MainTex("Main Tex", 2D) = "white" {}  //主纹理
	    _MainColor("MainColor",Color) = (1,1,1,1) 
		_BumpMap("Bump Map",2D) = "bump" {}  //法线纹理
		_RimColor("Rim Color",Color) = (0.46,0.0,1.0,0.0) //模型边缘颜色
		_RimPower("Rim Power",Range(0.2,2.0)) = 0.5   //边缘强度放大的倍数
		_Brightness("Brightness",Range(0.0,3.0)) = 1.0 //光强
		_EmissTex("EmissTex", 2D) = "white" {}
		_EmissColor("EmissColor",Color) = (1,1,1.1) 
		_Emiss("Emiss", Float) = 1
		_FlowTex("FlowTex", 2D) = "white" {}
		_FlowAlpha("FlowAlpha", Float) = 1
		_Flow_U("Flow_U", Float) = 0
		_Flow_V("Flow_V", Float) = 0	   
	}
	SubShader
	{
		Tags {  "RenderType" = "Transparent" "Queue" = "Transparent" "IgnoreProject" = "True" }
		Pass{
			ZWrite On 
			ColorMask 0
		}
		
		CGPROGRAM
		#pragma surface surf Lambert alpha noambient nodirlightmap novertexlights
		struct Input {
			float2 uv_MainTex;
			float2 uv_BumpMap;
			float3 viewDir;
		};
		sampler2D _MainTex;
		float4 _MainColor;
		sampler2D _BumpMap;
		float4 _RimColor;
		float _RimPower;
		float _Brightness;
		sampler2D _EmissTex; float4 _EmissTex_ST;
		float4 _EmissColor;
		float _Emiss;
	    float4 _TimeEditor;
	    sampler2D _FlowTex; float4 _FlowTex_ST;
		float _Flow_U, _Flow_V, _FlowAlpha;
		void surf(Input IN, inout SurfaceOutput o)
		{
			half4 basecol = tex2D(_MainTex, IN.uv_MainTex);
			half3 graycol = dot(basecol.rgb, float3(0.3, 0.59, 0.11))*_MainColor.rgb;

			float4 timeVal = _Time + _TimeEditor;
			float2 uv_new = (IN.uv_MainTex + (timeVal.g*float2(_Flow_U, _Flow_V)));
			float4 flowTex_var = tex2D(_FlowTex, TRANSFORM_TEX(uv_new, _FlowTex));
			float4 emissColor = _EmissColor*_Emiss;
			emissColor.rgb += graycol;
			half4 emissTex = tex2D(_EmissTex, IN.uv_MainTex);
			graycol = lerp(emissColor, graycol, emissTex.r);

			o.Albedo = graycol;
			o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
			half rim = 1.0 - saturate(dot(normalize(IN.viewDir), o.Normal));
			o.Emission = lerp(emissColor,_RimColor.rbg*pow(rim, _RimPower)*_Brightness+ flowTex_var.rgb*_FlowAlpha, emissTex.r);
			o.Alpha = (o.Emission.r + o.Emission.g + o.Emission.b) / 3.0;
			
		}
		ENDCG
	}
}

你可能感兴趣的:(unity3d,shader,unity,材质,游戏引擎)