纹理法线是根据纹理的每个纹素的颜色计算出来的吗?

Is the texture normal calculated from the color of each texel of a texture?

在normal mapping中,使用的贴图除了贴图颜色之外,还有贴图法线,就像下面的fragment shader代码:

#version 420 core
out vec4 color;
// Color and normal maps
layout ( binding = 0) uniform sampler2D tex_color;
layout ( binding = 1) uniform sampler2D tex_normal;

但是我不明白的是'texture normal'是什么类型的图像? 我还搜索了一些用于使用 RGB 颜色计算纹理法线的解决方案:

Red maps from (0-255) to X (-1.0 - 1.0)
Green maps from (0-255) to Y (-1.0 - 1.0)
Blue maps from (0-255) to Z (0.0 - 1.0)

法线贴图通常本身就是一幅图像,而不是嵌入到另一幅图像中的东西。正如您找到的描述所暗示的那样,给定点的法线是由该点法线贴图图像的 RGB 值确定的。这是一个示例,来自 Wikipedia article on normal mapping:

您发布的着色器代码需要两个单独的纹理,第一个是 material 的颜色,第二个是它的法线贴图。