首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >射线追踪-穿过树

射线追踪-穿过树
EN

Stack Overflow用户
提问于 2014-04-05 21:14:31
回答 3查看 154关注 0票数 0

我写了一个射线追踪程序,除了我用来遍历射线树的算法之外,一切似乎都在起作用,但我不确定这是正确的。在每个碰撞点,程序存储物体的颜色、反射指数和该点的光强度(镜面和漫射,环境是常数)。有人能帮我解释一下,当我穿过光线树的时候,我应该如何把物体的颜色和光的强度结合起来呢?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-04-06 09:28:00

来自Nvidia开发区

surfaceColor =发射+环境+漫射+镜面

这里,

  • 发射= Ke 其中:
代码语言:javascript
运行
复制
- Ke is the material's emissive color.

  • 环境= Ka x globalAmbient 其中:
代码语言:javascript
运行
复制
- Ka is the material's ambient reflectance and
- globalAmbient is the color of the incoming ambient light.

  • 漫射= Kd x lightColor x max(N·L,0) 其中:
代码语言:javascript
运行
复制
- 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 x lightColor x面x (max(N·H,0))^shininess 其中:
代码语言:javascript
运行
复制
- 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. 

票数 1
EN

Stack Overflow用户

发布于 2014-04-06 09:13:42

我认为你应该使用局部照明模型。U有计算这个反射模型的所有值:Phong反射模型

票数 0
EN

Stack Overflow用户

发布于 2014-04-06 09:43:43

最简单的是,对于多个对象,其中n是当前对象:

每个物体接收到下一个物体发出的光。

代码语言:javascript
运行
复制
incoming_light[n] = outgoing_light[n+1]

每个物体接收到的光都通过其漫射颜色和入射角(光线方向和正常方向的点乘积,如果你发出的光线已经是余弦分布的话,你可以跳过它):

代码语言:javascript
运行
复制
outgoing_light[n] += incoming_light[n] * diffuse[n] * cosine_term[n]

最后,像素颜色就是你击中的第一个物体发出的光。

代码语言:javascript
运行
复制
final_color = outgoing_light[0]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22886898

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档