从高度图计算法线(Calculate Normals from Heightmap)
我正在尝试使用中央差分将高度图转换为法线矩阵,后者将对应于给定点的陡度。
我找到了几个有正确结果的链接,但没有解释背后的数学问题。
T
L O R
B
从这个链接我意识到我可以做到:
Vec3 normal = Vec3(2*(R-L), 2*(B-T), -4).Normalize();
事情是,我不知道2*和-4来自哪里。
在这个关于中心差分的解释中,我看到我们应该将这个值除以2,但我仍然不知道如何连接所有这些。
我真正想知道的是这背后的线性代数定义。 我有一个高度图,我想测量中心差异,我想获得正常的矢量,以便稍后用来测量陡度。
PS:Z轴是高度。
I am trying to convert an heightmap into a matrix of normals using central differencing which will later correspond to the steepness of a giving point.
I found several links with correct results but without explaining the math behind.
T
L O R
B
From this link I realised I can just do:
Vec3 normal = Vec3(2*(R-L), 2*(B-T), -4).Normalize();
The thing is that I don't know where the 2* and -