【发布时间】:2015-06-01 22:42:25
【问题描述】:
我一直在互联网上寻找公式来计算光线追踪器中给定像素的漫反射值(当然,光线相交的地方)。
我发现的示例都涉及将颜色乘以其他颜色。 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 值提高到与材质的光泽度系数相等的幂,这又是 3 分量数据类型本身的乘积。
这可能是我对数学感到困惑,但如果有人能解决这个问题,将不胜感激。
【问题讨论】:
标签: opengl math graphics rgb raytracing