计算像素的镜面反射值?
Computing a pixel's specular value?
我一直在互联网上寻找计算光线跟踪器中给定像素漫反射值的公式(当然发生光线交叉的地方)。
我找到的例子都涉及将颜色与其他颜色相乘。 Nvidia的公式如下:
diffuse = Kd x lightColor x max(N · L, 0)
其中:
- Kd is the material's diffuse color
- lightColor is the color of the incoming diffuse light
- N is the normalized surface normal
- L is the normalized vector toward the light source
- P is the point being shaded
这个公式对我来说似乎并不难,但是在尝试对其进行编程时我发现 Kd x lightColour
是 2 个 RGB 值的乘积。这让我感到困惑,因为除非只是将 R、G 和 B 值相乘,否则无法像这样相乘。
同样,镜面反射公式要求将 RGB 值提高到等于 material 的反光系数的幂,这又是 3 分量数据类型本身的乘积。
这可能是我对数学感到困惑,但如果有人能解决这个问题,我们将不胜感激。
Kd x lightColour 是分量乘法:
a d a*d
[ b ] x [ e ] = [ b*e ]
c f c*f
在镜面光照的公式中(假设你说的是phong或blinn-phong光照模型),向量没有幂运算。
specular = ks x lightcolor x (R · V)^a
R · V
的结果是一个浮点数,因此幂只作用于一个数字。
我一直在互联网上寻找计算光线跟踪器中给定像素漫反射值的公式(当然发生光线交叉的地方)。
我找到的例子都涉及将颜色与其他颜色相乘。 Nvidia的公式如下:
diffuse = Kd x lightColor x max(N · L, 0)
其中:
- Kd is the material's diffuse color
- lightColor is the color of the incoming diffuse light
- N is the normalized surface normal
- L is the normalized vector toward the light source
- P is the point being shaded
这个公式对我来说似乎并不难,但是在尝试对其进行编程时我发现 Kd x lightColour
是 2 个 RGB 值的乘积。这让我感到困惑,因为除非只是将 R、G 和 B 值相乘,否则无法像这样相乘。
同样,镜面反射公式要求将 RGB 值提高到等于 material 的反光系数的幂,这又是 3 分量数据类型本身的乘积。
这可能是我对数学感到困惑,但如果有人能解决这个问题,我们将不胜感激。
Kd x lightColour 是分量乘法:
a d a*d
[ b ] x [ e ] = [ b*e ]
c f c*f
在镜面光照的公式中(假设你说的是phong或blinn-phong光照模型),向量没有幂运算。
specular = ks x lightcolor x (R · V)^a
R · V
的结果是一个浮点数,因此幂只作用于一个数字。