码迷,mamicode.com
首页 > 其他好文 > 详细

【Shader】人物选中高亮状态

时间:2017-08-05 14:11:42      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:tput   lin   str   unp   pack   diffuse   限制   color   tracking   

Shader
"OutLine/RedOutLine"
{
	Properties
	{
		_Switch("Value",Range(0,1)) = 0
		_MainTex("Texture",2D) = "white"{}
		_BumpMap("Bumpmap",2D) = "bump" {}
		_RimColor("RimColor",Color) = (0.26,0.19,0.16,0.0)
		_RimPower("RimPower",Range(0.5,8.0)) = 3.0
	}
		SubShader
	{
		Tags{
		"RenderType" = "Opaque"
	}
		CGPROGRAM

#pragma surface surf Lambert

	struct
		Input {
		float2 uv_MainTex;
		float2 uv_BumpMap;
		float3 viewDir;
	};
	sampler2D _MainTex;
	sampler2D _BumpMap;
	float4 _RimColor;
	float _RimPower;
	float _Switch;
	void
		surf(Input IN, inout SurfaceOutput o) {
		o.Albedo =
			tex2D(_MainTex, IN.uv_MainTex).rgb;
		o.Normal =
			UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
		half rim = 0;
		if (_Switch != 0)
		{
			 rim = 1.0 - saturate(dot(normalize(IN.viewDir), o.Normal));
		}
		
		

		
		
		//saturate
		//限制值于[0,1]之间
			o.Emission = _RimColor.rgb * pow(rim, _RimPower);
	}
	ENDCG
	}

		Fallback "Diffuse"
}

【Shader】人物选中高亮状态

标签:tput   lin   str   unp   pack   diffuse   限制   color   tracking   

原文地址:http://www.cnblogs.com/jhcelue/p/7289999.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!