v2f vert(a2v v){
//return UnityObjectToClipPos(v);
v2f f;
f.position = UnityObjectToClipPos(v.vertex);
//return UnityObjectToClipPos(v.vertex);
//f.temp = v.normal;
fixed3 ambient = UNITY_LIGHTMODEL_AMBIENT.rgb;//UNITY_LIGHTMODEL_AMBIENT 环境光?
fixed3 normalDir = normalize( mul(v.normal,(float3x3)unity_WorldToObject));
fixed3 lightDir = normalize(_WorldSpaceLightPos0.xyz);//对于每一个顶点来说,光的位置就是光的方向,因为光是平行光
fixed3 diffuse = _LightColor0.rgb * max(dot(normalDir,lightDir),0)*_Diffuse.rgb;//取得漫反射的颜色
//高光
fixed3 reflectDir = normalize(reflect(-lightDir,normalDir));
fixed3 viewDir = normalize(_WorldSpaceCameraPos.xyz - mul(v.vertex, unity_WorldToObject).xyz);//相机单位化的向量
fixed3 specular = _LightColor0.rgb * pow( max( 0 , dot(reflectDir,viewDir) ),10);
//fixed3 specular = _LightColor0.rgb * pow( max( 0 , 1),10);
f.color = diffuse + ambient + specular;
//f.color = diffuse + ambient;
return f;
}
fixed4 frag(v2f f) : SV_Target {
//return fixed4(0.5,0.9,1,1);
//return fixed4(f.temp,1);
return fixed4(f.color,1);
}