reprinted from the Wind Yu Chong Unity3d Tutorial CollegeTo put it simply, the final color output of the illuminated shader is the material color * light color, wherematerial Color: Previously mentioned, fixed formatTex2d (_maintex, I.UV) light color: light color =Spontaneous Light+Ambient Light+Diffuse Reflection Light+Mirror LightThese four types of light are explained in detail below
One: Spontaneous lightlight emitted from the surface of an object to all directionsemissive = coloremissivecoloremissive self-luminous color
II:
ambient light The surface of the object receives light from all directions and then bounces in all directions .Ambient = Ka * Colorambientka ambient light factor colorambient ambient light color
what is normal? Normal, normal line, is always perpendicular to a plane of a vector, impartial, like a judge, so named Normal. The normals of a point on a surface refer to the straight line (that is, the vector) that passes this point and is perpendicular to the tangent plane. Normals are directional: In general, the interior of the stereo is pointing outward from the normal direction of the normals, in turn the negative direction of the normals.
Three:
diffuse reflection light The main difference between diffuse reflectance and specular reflection is the distribution of normals. If the object is completely smooth, then the normals are completely perpendicular to the plane, such as mirrors and polished metal surfaces. And a lot of seemingly smooth and flat objects, such as paper, desktop, clothing, etc., in fact, with a magnifying glass to observe carefully, you will see its surface is uneven. The normal is not perpendicular to the face visible to the naked eye, but parallel to the actual face. Diffuse reflection: When the light is emitted to a rough surface, the surface will reflect the light in all directions, so even if the rays are parallel to each other, the reflected light is reflected irregularly in different directions due to the inconsistent normal direction of the points. This reflected light is called diffuse light.
calculation of Diffuse reflectionDiffuse = kd x colorlight x Max (n*l,0) KD diffuse reflectance coefficient colorlight the color of the light n unit normal vector L is the unit vector of the light source from the point where N and L are multiplied, and if the result is less than or equal to 0, the diffuse is 0.
Four:
specular reflection light 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 light color n unit normal vector L the unit vector V pointing to the light source by point points to the observer's unit vector H (l+v) vector, i.e. normalize (L+V) shininess specular strength coefficient, the smaller the value, the more dispersed the high light , the higher the value, the more concentrated the highlight. 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
Diffuse reflection and specular reflection
The way the light is reflected is mainly determined by the material's surface. If you are from the same single light source, the light source color colorlight is the same when you calculate it. The core is the point multiplication operation in which the unit normals participate. Diffuse reflection is only related to the incident angle of the light and the angle of incidence of the light and the angles of the viewer.
a
light model in Surface shader
In short, Lambert is diffuse, blinnphong with specular reflections. The relevant definitions can be
Lighting.cginc里查看
Blinn-phong:An evolving lighting model for the Phone reflection model. The default lighting model for OpenGL and D3D fixed pipelines, the illumination is calculated at the vertex stage, and then the value of the pixel between vertices is obtained by interpolation.
Http://en.wikipedia.org/wiki/blinn–phong_shading_model
Lambert:
Diffuse only, independent of the Observer (camera) perspective.
Unity3d Tutorial Shader: The 15th Light Foundation