高亮效果,使用Shader可以轻松实现

高亮效果,使用Shader可以轻松实现

效果图



Shader代码

[cpp]  view plain copy
  1. Shader "Rim"  
  2. {  
  3.   
  4.     Properties  
  5.     {  
  6.         _Color ("Main Color", Color) = (1,1,1,1)  
  7.         _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)  
  8.         _Shininess ("Shininess", Range (0.01, 1)) = 0.078125  
  9.         _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}  
  10.         _Illum ("Illumin (A)", 2D) = "white" {}  
  11.         _BumpMap ("Normalmap", 2D) = "bump" {}  
  12.         _EmissionLM ("Emission (Lightmapper)", Float) = 0  
  13.         _RimColor ("Rim Color", Color) = (0.26,0.19,0.16,0.0)  
  14.         _RimPower ("Rim Power", Range(0.5,8.0)) = 3.0  
  15.     }  
  16.   
  17.     SubShader  
  18.     {  
  19.         Tags { "RenderType"="Opaque" }  
  20.         LOD 400  
  21.         CGPROGRAM  
  22.           
  23.         #pragma surface surf BlinnPhong  
  24.   
  25.         sampler2D _MainTex;  
  26.         sampler2D _BumpMap;  
  27.         sampler2D _Illum;  
  28.         fixed4 _Color;  
  29.         half _Shininess;  
  30.         float4 _RimColor;  
  31.         float _RimPower;  
  32.   
  33.         struct Input  
  34.         {  
  35.             float2 uv_MainTex;  
  36.             float2 uv_Illum;  
  37.             float2 uv_BumpMap;  
  38.             float3 viewDir;  
  39.         };  
  40.   
  41.         void surf (Input IN, inout SurfaceOutput o)  
  42.         {  
  43.             fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);  
  44.             fixed4 c = tex * _Color;  
  45.             o.Albedo = c.rgb;  
  46.             o.Gloss = tex.a;  
  47.             o.Alpha = c.a;  
  48.             o.Specular = _Shininess;  
  49.             o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));  
  50.             half rim = 1.0 - saturate(dot(normalize(IN.viewDir), o.Normal));  
  51.             o.Emission = c.rgb * tex2D(_Illum, IN.uv_Illum).a + _RimColor.rgb * pow (rim, _RimPower);  
  52.         }  
  53.           
  54.         ENDCG  
  55.     }  
  56.     FallBack "Self-Illumin/Bumped Specular"  
  57. }  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值