First, the theory
Equation 1: The color formula that the illuminated object eventually renders
Final color = material Color * Glow Color
Equation 2: Material color
tex2d (_MAINTEX,UV)
Equation 3: Light color
Illumination color = Spontaneous light + ambient light + diffuse reflection + specular reflection
Equation 5: Self-illumination
emissive = coloremissive
Coloremissive Self-luminous colors
Equation 6: Ambient light
Ambient= ka*colorambient
Ka Ambient light factor
Colorambient Ambient light Color
Equation 7: Diffuse reflection light
Diffuse=kd*colorlight*max (dot (n,l), 0)
Kd Diffuse reflectance coefficient
Colorlight Light Color
N normal vector
L Light Source Direction
Equation 8: Specular reflection
Specular reflection: light to the surface smooth, normal uniform surface of the object, this reflected light is called specular reflection light. Ks Mirror coefficient colorlight The color of the light n unit normal vector L is the unit vector of the light source from the point to the units of the observer's unit vector H (l+v) vector, i.e. normalize (l+v) shininess Specular strength coefficient, the smaller the value, the more diffuse the high light, the higher the value, the more concentrated the high light. Facing if the dot multiplication of N and L is greater than 0, then facing is 1 and if less than or equal to 0, then facing is 0
Unity3d "Shader" Custom illumination model