Unity 不受光照影响shader 仿Unlit/Texture

  • Post author:
  • Post category:其他

Unity 不受光照影响 shader ,类似 Unlit/Texture” shader

一:

Shader "Custom/MyShader" {
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)//Tint Color
	_MainTex ("Base (RGB)", 2D) = "white" {}
}

SubShader {
	Tags {  "RenderType"="Opaque" }
	LOD 100

	Pass {
	    cull front
		Lighting Off
		SetTexture [_MainTex] { combine texture } 
		SetTexture [_MainTex]
		{
			ConstantColor [_Color]
			Combine Previous * Constant
		}
	}
}
}

下面是我用surf shader 实现的

二 :

Shader "Custom/SurfTexture" {
	Properties {
		_Color ("Main Color", Color) = (1,1,1,1)
		_MainTex ("Base (RGB)", 2D) = "white" {}
		
	}
	SubShader {
		Tags { "RenderType"="Opaque" }
		LOD 200
		
		CGPROGRAM
		#pragma surface surf myLightModel  

		//命名规则:Lighting接#pragma suface之后起的名字 
  		//lightDir :点到光源的单位向量   viewDir:点到摄像机的单位向量   atten:衰减系数 
  		float4 LightingmyLightModel(SurfaceOutput s, float3 lightDir,half3 viewDir, half atten) 
  		{ 
  		 	float4 c ; 
  		 	c.rgb =  s.Albedo;
  			c.a = s.Alpha; 
    		        return c; 
  		}

		sampler2D _MainTex;
                float4 _Color;
        
		struct Input {
			float2 uv_MainTex;
			float4 _Color;
		};

		void surf (Input IN, inout SurfaceOutput o) {
			half4 c = tex2D (_MainTex, IN.uv_MainTex)*_Color;
			o.Albedo = c.rgb;
			o.Alpha = c.a;
		}
		ENDCG
	} 
	FallBack "Diffuse"
}

相关链接:http://ykxingquan.blog.163.com/blog/static/13428052013052420979/


版权声明:本文为ak4100原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。