1. Fresnel Effect
In general, when the light reaches the contact surface of two kinds of materials, some light is reflected out on the contact surface, and another part of the light will be reflected through the contact surface, this phenomenon is calledFresnel Effect. The Fresnel formula describes how much light is reflected and how much light is reflected. The following is an approximation of the Fresnel formula:
Reflectioncoefficient = max (0, min (1, bias + scale x (1 + I · N) power ))
The range of the reflection coefficient reflectioncoefficient is limited to [0, 1]. We use reflectioncoefficient to mix the reflection and refraction Vectors based on the following formula (C stands for the color ):
Cfinal = reflectioncoefficient × creflected + (1-reflectioncoefficient) × crefracted
There is also a commonly used formula for Approximate Calculation of Fresnel:
Fastfresnel = R + (1-r) * POW (1.0-dot (viewdir, normal), 5.0 );
The reflection coefficient R value can be obtained through physical measurement. For example, the air-to-water reflection coefficient is about 0.02037.
Thus
Cfinal = fastfresnel × creflected + (1-fastfresnel) × crefracted
2. color dispersion
In addition to the surface vector, incident angle, and refractive coefficient ratio, the refraction volume also depends on the wavelength of the incident light. For example, red light is much more refraction than blue light. This phenomenon is calledColor dispersion(Chromatic dispersion ). This is why a rainbow is formed when white light enters the prism.
A real light has a wavelength, not just three special discrete wavelengths. However, we can simulate only the wavelength of the red, green, and blue components of light. Practice has proved that this approximation is effective.
Combining the color dispersion Fresnel effect will create a rainbow effect, as if the rendered object is made of crystal.