本文主要是介绍unity shader 幽灵材质,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
先上图:
上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 novertexlightsstruct 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}
}
这篇关于unity shader 幽灵材质的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!