DX12-8th

算是复习一点 games101 的东西了。

2.2

变换法向量,证明过程使用 unT = u·n 蛮有意思

4

朗伯余弦定理,辐射通量(radiant flux),辐照度(irradiance)。

5

漫反射(diffuse)

6

环境光(ambient),用于简单模拟其他物体反射过来的间接光照

7

Fresnel equations(菲涅尔等式),Schlick approximation

粗糙度(roughness),镜面瓣(specular lobe)
镜面反射光(specular )

image-20220316170926311

8

总结了光照模型的概述

线

在书中的着色器代码中也控制了 n·h 非负

9

一些名词
光泽度(shininess)粒度(granularity)

16.1

Modify the lighting demo of this chapter so that the directional light only emits mostly red light. In addition, make the strength of the light oscillate as a function of time using the sine function so that the light appears to pulse. Using colored and pulsing lights can be useful for different game moods; for example, a pulsing red light might be used to signify emergency situations

上传前改个常量缓冲区数据,mMainPassCB.Lights[0].Strength = { fabsf(sinf(20*gt.TotalTime())), 0.0f, 0.0f };
GIF 2022-3-17 13-30-23

16.2

Modify the lighting demo of this chapter by changing the roughness in the materials

调整粗糙度,matConstants.Roughness 修改这个即可,稍微比对一下 1.0f 与 0.0f 的区别

以下有点偷懒,其实是要去改材质的,我直接改了所有的。只对一个修改只需要在 LitColumnsApp::BuildMaterials 中修改即可。

Roughness = 0.0f

image-1.0f

Roughness = 1.0f

image-20220317134844373

这个粗糙度给人感觉有点奇怪。由于 R0 还是挺高的,反射光量也很高,看起来不那么粗糙。

Roughness = 1.0f , matConstants.FresnelR0 = DirectX::XMFLOAT3(0.0f,0.0f,0.0f);

image-20220317135252971

这样子确实是粗糙了点,但是不知道为什么走样有点明显。

16.3

三点布光。具体应该怎么打光应该查一下资料,这里了解一下概念即可。

16.6

One characteristic of cartoon styled lighting is the abrupt transition from one color shade to the next (in contrast with a smooth transition) as shown in Figure 8.30. This can be implemented by computing kd and ks in the usual way, but then transforming them by discrete functions like the following before using them in the pixel shader: Modify the lighting demo of this chapter to use this sort of toon shading. (Note: The functions f and g above are just sample functions to start with, and can be tweaked until you get the results you want.)

卡通风格,书中的例子可以通过修改着色器代码实现,不过添加了分支,不太好。

水流的效果只用了一个直接光,那我就改一下那个看看。

// 如果没有把所有可能包含进去会报错,不是很理解成因
float kdtrans(float kd)
{
    if(kd <= 0.0f){
        return 0.4f;
    }else if(kd <= 0.5f){
        return 0.6f;
    }else if(kd <= 1.0f){
        return 1.0f;
    }else{
        return 1.0f;
    }
}

float kstrans(float ks)
{
    if(ks <= 0.0f){
        return 0.0f;
    }else if(ks <= 0.1f){
        return 0.0f;
    }else if(ks <= 0.8f){
        return 0.5f;
    }else if(ks <= 1.0f){
        return 0.8f;
    }else{
        return 0.8f;
    }
}
//修改直接光模型
float ndotl = kdtrans(max(dot(lightVec, normal), 0.0f));
//修改BlinnPhong模型
float roughnessFactor = (m + 8.0f)*kstrans(pow(max(dot(halfVec, normal), 0.0f), m)) / 8.0f;

没有使用卡通风格

image-20220317141646375

卡通风格

image-20220317142548686