作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个关于光线追踪中区域照明的快速问题。我正在从 Ray Tracing from the Ground Up 学习这个主题当没有应用抗锯齿时,我的区域光的结果是这样的:
如您所见,图像中有很多噪点。当我应用抗锯齿时,它看起来不错,应用 256x AA 时看起来像这样:
[阴影颜色的变化是微不足道的,我改变了阴影的一些属性]
我的问题是,这是区域灯的行为方式还是我做错了什么?因为渲染第一个只需要 4 秒,而后一个需要将近 20 分钟。感觉哪里不对。
我的点光源类和面光源类之间的唯一区别是 get_direction
函数。
点光源的get_direction
函数:
virtual Vec get_direction(ShadeRec& sr)
{
return Vec(position.x-sr.hit_point.x, position.y-sr.hit_point.y, position.z-sr.hit_point.z).norm();
}
区域光的get_direction
函数:
virtual Vec get_direction(ShadeRec& sr)
{
Vec newLocation;
newLocation.x = position.x + radius * (2.0 * rand_float() - 1.0);
newLocation.y = position.y + radius * (2.0 * rand_float() - 1.0);
newLocation.z = position.z + radius * (2.0 * rand_float() - 1.0);
return ((newLocation - sr.hit_point).norm());
}
最佳答案
您发布的渲染时间对我来说非常有意义:
4 seconds * 256 ~= 17 minutes
随机数生成器引入的开销加起来就是其余部分。
关于graphics - 光线追踪中的区域照明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11953825/
我正在尝试使用 Sfml 编写 2D 游戏。对于那个游戏,我需要一个 Lightengine 和一些代码,这些代码可以为我提供玩家可见的世界区域。由于这两个问题非常吻合(实际上是相同的),我想同时解决
我是一名优秀的程序员,十分优秀!