突然就全程看不懂了!!!!看不懂!!!
好懵逼!!!!懵逼!!!
镜面反射的数量_specularAmount,range
强弱_SpecularPower
方向_AnisoDir,2D
纹理的偏移控制_AnisoOffset ,range(-1,1)
声明变量
#pragma surface surf AnisotropicSpec
创建自定义的表面输出结构体
struct SurfaceAnisoOutput{
fixed3 Normal;
fixed3 Emission;自发光
fixede3 AnisoDirection;各向异性方向
half Specular;镜面反射系数
fixerde Gloss;高光系数
fixede ALpha;
}
void surf(Input In,inout SurfaceAnisoOutput o)
fixed4 LightingAnisotropicSpec(SurfaceAnisoOutputs,fxied3 lightdir,half3 viewDir,fixed atten{}
fixed3 halfVector=normallize(normalize(lightDir,)normal(viewDir));
float NdotL=saturate(dot(s.normal,lightDir));
fixed HdotA=dot(normallize(s.Normal,s.AnisoDirection),halvVector);
float aniso=max(0,sin(radians(HdotA+_AnisoOffset)*180));各向异性系数
float spec=saturate(
pow(aniso,s.Gloss*128)*s._SpecularAmount
)
c.rgb=(s.Albedo*_LightColor0*NdotL+_LightColor0.rgb*_SpecularColor.rgb*spec)*atten;
c.a=s.Alpha;
return c;
)