1Shader"Custom/ill_rimlight" 2 {3 Properties {4_color ("Main Color", Color) = (.5,.5,.5,1)5_outlinecolor ("Rim Color", Color) = (0,0,0,1)6_outline ("Rim Width", Range (.002,0.03)) = .0057_maintex ("Base (RGB)", 2D) =" White" { }8_illum ("illumin (A)", 2D) =" White" { }9_EMISSIONLM ("emission (Lightmapper)", Float) =0Ten } One A Subshader - { - theTags {"Rendertype"="Opaque" } -Lod $ - - Cgprogram + #pragmaSurface Surf Lambert - + sampler2d _maintex; A sampler2d _illum; at fixed4 _color; - - structInput { - float2 Uv_maintex; - float2 Uv_illum; - }; in - voidSurf (Input in, InOut surfaceoutput o) { toFixed4 Tex =tex2d (_maintex, In.uv_maintex); +FIXED4 C = Tex *_color; -O.albedo =C.rgb; theO.emission = C.rgb *tex2d (_illum, In.uv_illum). A; *O.alpha =C.A; $ }Panax Notoginseng ENDCG - the Pass + { A Cginclude the#include"Unitycg.cginc" + - structAppData { $ float4 vertex:position; $ FLOAT3 Normal:normal; - }; - the structv2f { - float4 pos:position;Wuyi float4 Color:color; the }; - WuUniformfloat_outline; - uniform float4 _outlinecolor; About $ v2f Vert (AppData v) { - v2f o; -O.pos =Mul (UNITY_MATRIX_MVP, V.vertex); - AFLOAT3 norm =Mul ((float3x3) UNITY_MATRIX_IT_MV, v.normal); +FLOAT2 offset =transformviewtoprojection (NORM.XY); the -O.pos.xy + = offset * O.POS.Z *_outline; $O.color =_outlinecolor; the returno; the } the ENDCG the -Name"OUTLINE" inTags {"Lightmode"=" always" } the Cull Front the Zwrite on About Colormask RGB the Blend Srcalpha Oneminussrcalpha the the Cgprogram + #pragmaVertex vert - #pragmaFragment Frag theHalf4 Frag (v2f i): COLOR {returnI.color;}Bayi ENDCG the } the } - -Fallback"Self-illumin/vertexlit" the}
Shader of Unity3d with spontaneous light and marginal highlight