码迷,mamicode.com
首页 > 编程语言 > 详细

Unity Shader 模型流光效果

时间:2017-09-30 19:46:12      阅读:374      评论:0      收藏:0      [点我收藏+]

标签:sample   diff   http   highlight   csharp   clu   float   unity   position   

技术分享

 

Shader "Custom/FlowColor" {
	Properties {
		_MainTex ("Base (RGB)", 2D) = "white" {}
		_FlowColor("Flow Color", Color) = (1,1,1,1)
		_FlowRange("Flow Range", Float) = 0.01
	}

	SubShader {

		
		Pass
        {

		Tags {   "Queue" = "Geometry" }

		CGPROGRAM

        #include "UnityCG.cginc"

		struct v2f
		{
			float4 vertex:POSITION;
			float2 uv:TEXCOORD0;
			float nr:TEXCOORD1;
		};

		sampler2D _MainTex;
		float4 _FlowColor;
		float _FlowRange;

		v2f vert(appdata_base  v)
		{
			
			v2f o;
			o.uv = v.texcoord;
			o.vertex = mul(UNITY_MATRIX_MVP,v.vertex);
			float2 dir = normalize(float2(cos(_Time.y),sin(_Time.y)));
			float2 worldNormal = normalize(mul((float3x3)_Object2World,v.normal)).xz;
			
			o.nr = dot(dir,worldNormal);
						

			return o;
		}

		fixed4 frag (v2f IN):COLOR
		{
			//fixed4  c = tex2D(_MainTex, IN.uv);
			fixed fac = saturate(sign(IN.nr *(IN.nr-_FlowRange)));
			fixed4 c=fac*tex2D(_MainTex, IN.uv) +(1-fac)*_FlowColor;
			return c;
		}

        #pragma vertex vert
        #pragma fragment frag

		ENDCG
		}

		
	} 
	FallBack "Diffuse"
}

  

 

Unity Shader 模型流光效果

标签:sample   diff   http   highlight   csharp   clu   float   unity   position   

原文地址:http://www.cnblogs.com/mrblue/p/7615734.html

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