Unity3D Shader : 边缘发光

Shader "Custom/Test"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_RimColor("RimColor",Color) = (1,1,1,1)
_BumpMap("Bump",2D) = "bump"{}
_RimPower("RimPower",Range(0.0,1.0)) = 0.5
_Amount("Amount",Range(-1,1))=0.5
}
SubShader
{
Tags { "RenderType" = "Opaque" }
LOD 200


CGPROGRAM
#pragma surface surf Lambert vertex:vert finalcolor:fina noforwardadd
#pragma target 3.0


sampler2D _MainTex;
fixed4 _RimColor;
half _RimPower;
half _Amount;
sampler2D _BumpMap;
struct Input {
float2 uv_BumpMap;
float2 uv_MainTex;
float3 viewDir;
};
void vert(inout appdata_full v)
{
v.vertex.xyz +=v.normal*_Amount;
}

void surf(Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
o.Albedo = c.rgb;
fixed rim =1- saturate(dot(normalize(IN.viewDir), o.Normal));
o.Emission = rim * _RimColor*(_RimPower + 0.5);

o.Alpha = c.a;
}
void fina(Input IN, SurfaceOutput o, inout fixed4 color)
{
color = color * 0.5 + 0.5;

}
ENDCG
}
FallBack"Diffuse"

}


猜你喜欢

转载自blog.csdn.net/weixin_42452001/article/details/80683549