书上的原话是:visualize the normals with a color map,但是代码实现的是光线撞上球,然后色彩表(RGB)可视化“撞点”的法向量。
开章第一句是“First, let’s get ourselves a surface normal so we can shade.”。这句话是看懂了“获取法向量是为了shade”,但是不知道具体是讲的是啥。为什么要可视化?为什么要用色彩表来可视化?shade时怎么用这个?不懂,但是还觉得很厉害的样子。
什么是法向量?什么是球的法向量?不解释,找初中数学老师。
在此讨论的法向量是单位法向量。
书上先介绍了球的法向量,然后直接承接
“Let’s that into the code now, and shade it”(太直接了啊,有木有??)
“We don’t have any lights or anything yet, so let’s just visualizethe normals with a color map.”(此处更加直接,直接跳到用色彩表可视化法向量。木有原因,木有理由,木有前戏,臣妾接受不了啊)
“A common trick used for visualizing normals is to map each componentto the interval from 0 to 1, and then map x/y/z to r/g/b”
(这句话的意思是:怎么用色彩表可视化(单位)法向量?将单位法向量的坐标x/y/z映射成r/g/b。具体做法:考虑x/y/z在[-1,1],r/g/b在[0,1],怎么映射?x/y/z分别+1然后/2)
看代码:(