我写了一个射线追踪程序,除了我用来遍历射线树的算法之外,一切似乎都在起作用,但我不确定这是正确的。在每个碰撞点,程序存储物体的颜色、反射指数和该点的光强度(镜面和漫射,环境是常数)。有人能帮我解释一下,当我穿过光线树的时候,我应该如何把物体的颜色和光的强度结合起来呢?
发布于 2014-04-06 09:28:00
来自Nvidia开发区:
surfaceColor =发射+环境+漫射+镜面
这里,
- Ke is the material's emissive color.
- Ka is the material's ambient reflectance and
- globalAmbient is the color of the incoming ambient light.
- 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, and
- P is the point being shaded.
- Ks is the material's specular color,
- lightColor is the color of the incoming specular light,
- N is the normalized surface normal,
- V is the normalized vector toward the viewpoint,
- L is the normalized vector toward the light source,
- H is the normalized vector that is halfway between V and L,
- P is the point being shaded, and
- facing is 1 if N · L is greater than 0, and 0 otherwise.
发布于 2014-04-06 09:13:42
我认为你应该使用局部照明模型。U有计算这个反射模型的所有值:Phong反射模型
发布于 2014-04-06 09:43:43
最简单的是,对于多个对象,其中n是当前对象:
每个物体接收到下一个物体发出的光。
incoming_light[n] = outgoing_light[n+1]每个物体接收到的光都通过其漫射颜色和入射角(光线方向和正常方向的点乘积,如果你发出的光线已经是余弦分布的话,你可以跳过它):
outgoing_light[n] += incoming_light[n] * diffuse[n] * cosine_term[n]最后,像素颜色就是你击中的第一个物体发出的光。
final_color = outgoing_light[0]https://stackoverflow.com/questions/22886898
复制相似问题