Light Model
Light Mode
参考子: Introduction to 3D Game Programming with directx12
Diffuse Light
The light will bounce around in the interior, where some of it will be absorbed and the remaining part scattered out of
the surface in every direction; this is called a diffuse reflection. In our approximation for modeling this kind
of light/material interaction, we stipulate that the light scatters out equally in all
directions above the surface; consequently, the reflected light will reach the eye .
We break the calculation of diffuse lighting into two parts. For the first part, we specify a light color and a diffuse albedo color.
The diffuse albedo specifies the amount of incoming light that the surface reflects due to diffuse reflectance
(by energy conservation, the amount not reflected is absorbed by the material).
This is handled with a component-wise color multiplication (because light can
be colored). For example, suppose some point on a surface reflects 50% incoming
red light, 100% green light, and 75% blue light, and the incoming light color is
80% intensity white light. That is to say, the quantity of incoming light is given by
$B_L = (0.8, 0.8, 0.8) $ and the diffuse albedo is given by $m_d =(0.5, 1.0, 0.75) $; then the
amount of light reflected off the point is given by:
The above formula is not quite correct, however. We still need to include
Lambert’s cosine law (which controls how much of the original light the surface
receives based on the angle between the surface normal and light vector). Let
\(B_L\) represent the quantity of incoming light, \(m_d\) be the diffuse albedo color, \(L\) be
the light vector, and n be the surface normal. Then the amount of diffuse light
reflected off a point is given by:
Ambient Ligth
To sort of hack this indirect light, we introduce an ambient term to the lighting equation:
The color \(A_L\) specifies the total amount of indirect (ambient) light a surface
receives, which may be different than the light emitted from the source due to the
absorption that occurred when the light bounced off other surfaces. The diffuse
albedo \(m_d\) specifies the amount of incoming light that the surface reflects due to
diffuse reflectance. We use the same value for specifying the amount of incoming
ambient light the surface reflects; that is, for ambient lighting, we are modeling
the diffuse reflectance of the indirect (ambient) light. All ambient light does is
uniformly brighten up the object a bit—there is no real physics calculation at all.
SPECULAR LIGHTING
Due to the Fresnel effect, when light reaches the
interface between two media with different indices of refraction some of the
light is reflected and the remaining light is refracted . The index
of refraction is a physical property of a medium that is the ratio of the speed of
light in a vacuum to the speed of light in the given medium. We refer to this light reflection process as specular reflection and the reflected light as specular light.
Fresnel effect
How much light is refl ected depends on the medium (some materials will be
more reflective than others) and also on the angle \(\theta\) between the normal vector
\(n\) and light vector \(L\). Due to their complexity, the full Fresnel equations are
not typically used in real-time rendering; instead, the Schlick approximation is
used:
Roughness
For a given view \(v\) and light vector \(L\), we want to know the fraction of microfacets that reflect \(L\) into
\(v\); in other words, the fraction of microfacets with normal \(h = normalize(L + v)\); This will tell us how much light is refl ected into the eye from
specular reflection—the more microfacets that reflect \(L\) into \(v\) the brighter the
specular light the eye sees.
We define the normalized distribution function \(\rho(\theta_h) \in [0, 1]\) to denote the
fraction of microfacets with normals \(h\) that make an angle \(\theta_h\) with the macro
normal \(n\).
We can combine \(\rho(\theta_h)\) with a normalization factor to obtain a new function that models the amount of specular reflection of light based on roughness:
[
\begin{aligned}
S(\theta_h) &= \frac{m+8}{8}\cos^m(\theta_h) \
&= \frac{m+8}{8}\big(\mathbf{n}\cdot\mathbf{h}\big)^m
\end{aligned}
]
To conclude this section, let us combine Fresnel reflection and surface roughness.
We are trying to compute how much light is reflected into the view direction \(\mathbf v\) (see Figure 8.18).
Recall that microfacets with normals \(\mathbf h\) reflect light into \(\mathbf v\).
Let \(\alpha_h\) be the angle between the light vector and half vector \(\mathbf h\), then \(\mathbf R_F(\alpha_h)\) tells us the amount of light reflected about \(\mathbf h\) into \(\mathbf v\) due to the Fresnel effect.
Multiplying the amount of reflected light \(\mathbf R_F(\alpha_h)\) due to the Fresnel effect with the amount of light reflected due to roughness \(S(\theta_h)\) gives us the amount of specular reflected light:
Let \(\big(\max(\mathbf L\cdot\mathbf n,0)\big)\cdot\mathbf B_L\) represent the quantity of incoming light that strikes the surface point we are lighting, then the fraction of \(\big(\max(\mathbf L\cdot\mathbf n,0)\big)\cdot\mathbf B_L\) specularly reflected into the eye due to roughness and the Fresnel effect is given by:
[
\mathbf c_s = \max(\mathbf L\cdot\mathbf n,0)\cdot\mathbf B_L \otimes \mathbf R_F(\alpha_h)\frac{m+8}{8}\big(\mathbf n\cdot\mathbf h\big)^m
]
Light Model
This leads to the lighting equation our shaders implement in this book:
[
\begin{aligned}
\text{LitColor} &= \mathbf c_a + \mathbf c_d + \mathbf c_s \
&= \mathbf A_L \otimes \mathbf m_d + \max(\mathbf L\cdot\mathbf n,0)\cdot\mathbf B_L \otimes \left(
\mathbf m_d + \mathbf R_F(\alpha_h)\frac{m+8}{8}\big(\mathbf n\cdot\mathbf h\big)^m
\right)
\end{aligned}
]
posted on 2026-08-26 14:35 Ultraman_X 阅读(3) 评论(0) 收藏 举报
浙公网安备 33010602011771号