float4 _EmissiveColor; float4 _AmbientColor; float _MySliderValue; void surf (Input IN, inout SurfaceOutput o) { // Albedo comes from a texture tinted by color float4 c; c = pow((_EmissiveColor + _AmbientColor), _MySliderValue); o.Albedo = c.rgb; // Metallic and smoothness come from slider variables o.Alpha = c.a;

1.如果没注意将_MySliderValue的数据类型声明成float4,那么shader将不会起作用并且不会报错。

CGPROGRAM
			#pragma surface surf BasicDiffuse

		inline float4 LightingBasicDiffuse(SurfaceOutput s,fixed3 lightDir, fixed atten)
	{
		float difLight = max(0, dot(s.Normal, lightDir));
		float4 col;
		col.rgb = s.Albedo * _LightColor0.rgb * (difLight * atten * 2);
		col.a = s.Alpha;
		return col;
	}

2.自建光照模型 定义要在#下

<1> 疑问:关于rgb的运算方式,是如何进行运算得出颜色值的,0,1对它的运算影响。

3. 报错Too many texture interpolators would be used for ForwardBase pass at line

错误原因是在报错Shader里,在结构体Input中定义了大于等于3个的额外的uv变量信息。?

struct Input {  
            float2 offset1;  
            float2 offset2;  
            float2 offset3;  
            float4 pos;  
            fixed4 color;  
        };  

<2> shader入门资料

http://www.360doc.com/content/13/0923/15/12282510_316492286.shtml