About lighting Models
The so-called model, which is usually initiated by an academic algorithm, is a reliable formula validated by a large amount of actual data.
Now remember the 2009 as a TD-SCDMA mobile communication algorithm, I have seen the free space propagation model (propagation models), in order to obtain the transmission loss of mobile signals. It was based on normal PC real-time operations and was very time-consuming – for example, the propagation model in Beijing's five rings took more than 20 minutes to render GIS maps.
There are 2 types of illumination model sources:
- A class is based on an academic paper algorithm, such as Lambert model, Phong model.
- Another type of algorithm-based variant – a modified model in practical production practices, such as the Halflambert model and the Blinnphong model.
Lighting Model formula:
Surfacecolor = emissive + ambient + diffuse + specular
The color of an object's surface is the sum of light effects such as self-illumination (emissive), environmental reflection (ambient), diffuse reflection (diffuse), and specular reflection (specular). Each light effect depends on the nature of the surface material (such as brightness and material color) and the nature of the light source (such as the position and color of the light).
In general, light models only consider diffuse and specular reflection .
Light Model classification
When light shines on the surface of the object, part of it is absorbed by the surface of the object, the other part is reflected, and for the transparent object, a part of the light passes through the transparent body, producing transmitted light. The light energy absorbed by the object is converted into heat, and only reflected and transmitted light can enter the eye, producing visual effects (the brightness and color of the object's appearance). Therefore, the light color of the object surface is determined by the incident light, the object material, and the interaction of material and light.
In addition, the most basic interaction between light and object is reflection , follow reflection: reflected light and incident light are located on the surface of the normal side, on the ideal reflective surface (such as mirror), the angle of incidence equals the reflection angle, the observer can only be seen on the surface of the normal direction of reflection on the side to see reflected light .
Unity built-in lighting model
On the unity surface shader (surface Shader), unity has built-in 2 lighting models for most scenarios.
Source path: C:\Program files\unity\editor\data\cgincludes\lighting.cginc
Lambert Diffuse Reflection
Fixed4 Lightinglambert (surfaceoutput s, Unitygi gi)
The surface of a rough object reflects light in all directions, such as the diffuse reflection of light (diffuse reflection), which is equivalent to scattering in all directions. The surface of the object that produces the diffuse reflection of light is called an ideal diffuse reflector, also known as a Lambert (Lambert) reflector. The Lambert model shows the phenomenon of illumination on rough surface, such as lime whitewashed wall, paper, blackboard and so on.
Blinnphong Specular Reflection (Jim Blinn 1977
)
It is based on the Phong model, the effect is to make the high light more soft, smoother, but the real sense has not Phong model strong, mainly is the model operation speed is fast, that is, the efficiency of the operation is high.
Fixed4 Lightingblinnphong (surfaceoutput s, half3 viewdir, Unitygi gi)
When a smooth object is illuminated by light, a strong reflected light can be seen in one direction, because in an area close to the specular reflection angle
, reflecting all or most of the light intensity of the incident light, the phenomenon is called specular reflection . Reflective luster, such as metallic material. Specular reflection considers the intensity of light to be correlated with the angle of the reflected light and line of sight.
In the OpenGL and Direct3D rendering pipeline, Blinn-phong is the default rendering model.
Some Lighting model concepts:
- Fresnel Fresnel Reflection : In the observation of the water, the vertical look down, crystal clear, look at the distant water, to the mirror, this is the Fresnel effect. The Fresnel effect can be said to be ubiquitous, with different material effects.
- specular color is usually the color of the material rather than the color of the light source.
- The plastic uses a white specular highlight, a large diffuse reflection component and a small specular reflection component.
- The reflection of metal usually occurs on the surface, the diffuse reflection component is very small, sometimes even can be neglected, the roughness value M is also very small.
- cook-torrance model : Simulates metal and plastic materials with a model, taking into account the color shifts that occur when the incident angle changes.
- Bank BRDF Illumination model : BRDF is the meaning of the bidirectional reflection distribution function, which describes the relative energy of the reflected light at a certain reflection angle of the incident light. Therefore, given the different BRDF functions, different illumination effects can be achieved, such as anisotropic illumination effect-metal surface drawing and other effects.
Reference Documentation:
- "Unity3d for VR Learning (8): Unity Shader Overview"
- "GPU Programming and CG language Spring Snow lowbrow. pdf"
- "Unity Shader and screen effects development tips –unity Shaders and effects Cookbook"
Please specify the transfer from Unity3d for VR Learning (9): Unity Shader Illumination Model (illumination models)
Unity3d for VR Learning (9): Unity Shader Illumination models (illumination model)