- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
你好,我正在研究光线追踪算法,但我被蒙特卡洛算法困住了。在没有区域光的情况下渲染时,我的渲染输出是正确的,但是当我将区域光实现添加到源代码以生成软阴影时,我遇到了问题。
这是前后输出图像。
当我向下移动蓝色球体时,问题仍在继续(请注意,当球体沿白色虚线移动时,伪影仍在继续)。请注意,此球体和区域光具有相同的 z 偏移量。当我将蓝色球体带到屏幕前时,工件消失了。我认为问题是由均匀采样锥或采样球函数引起的但不确定。
这里是函数:
template <typename T>
CVector3<T> UConeSample(T u1, T u2, T costhetamax,
const CVector3<T>& x, const CVector3<T>& y, const CVector3<T>& z) {
T costheta = Math::Lerp(u1, costhetamax, T(1));
T sintheta = sqrtf(T(1) - costheta*costheta);
T phi = u2 * T(2) * T(M_PI);
return cosf(phi) * sintheta * x +
sinf(phi) * sintheta * y +
costheta * z;
}
我正在从 van Der Corput 序列生成随机浮点值 u1、u2。这是球体采样法
CPoint3<float> CSphere::Sample(const CLightSample& ls, const CPoint3<float>& p, CVector3<float> *n) const {
// translate object to world space
CPoint3<float> pCentre = o2w(CPoint3<float>(0.0f));
CVector3<float> wc = Vector::Normalize(pCentre - p);
CVector3<float> wcx, wcy;
//create local coordinate system from wc for uniform sample cone
Vector::CoordinateSystem(wc, &wcx, &wcy);
//check if inside, epsilon val. this is true?
if (Point::DistSquare(p, pCentre) - radius*radius < 1e-4f)
return Sample(ls, n);
// Else outside evaluate cosinus theta value
float sinthetamax2 = radius * radius / Point::DistSquare(p, pCentre);
float costhetamax = sqrtf(Math::Max(0.0f, 1.0f - sinthetamax2));
// Surface properties
CSurfaceProps dg_sphere;
float thit, ray_epsilon;
CPoint3<float> ps;
//create ray direction from sampled point then send ray to sphere
CRay ray(p, Vector::UConeSample(ls.u1, ls.u2, costhetamax, wcx, wcy, wc), 1e-3f);
// Check intersection against sphere, fill surface properties and calculate hit point
if (!Intersect(ray, &thit, &ray_epsilon, &dg_sphere))
thit = Vector::Dot(pCentre - p, Vector::Normalize(ray.d));
// Evaluate surface normal
ps = ray(thit);
*n = CVector3<float>(Vector::Normalize(ps - pCentre));
//return sample point
return ps;
}
有人有什么建议吗?谢谢。
最佳答案
我解决了这个问题。
光线追踪需要更复杂的 RNG(其中一个 "The Mersenne Twister" 伪随机数生成器)和良好的混洗算法。
希望对您有所帮助。感谢所有发表评论的人。
关于c++ - 光线追踪不正确的软阴影采样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33755830/
我正试图找到一个基准来衡量用户愿意等待远程服务响应的时间。在我的例子中,响应是非常有用的,但不是对数据输入的业务关键验证。我想 HCI 领域一定已经在这方面做了一些工作。 如果您知道软实时响应的普遍接
这个问题在这里已经有了答案: What's the difference between SoftReference and WeakReference in Java? (12 个回答) 关闭6年前
社区维基 我不在乎声誉点,我只想要好的答案。请随意将此问题标记为社区 wiki。 上下文 我一直在研究《理性策划者》,并发现了以下观察结果: 逻辑编程非常有趣。 逻辑编程有时是违反直觉的 逻辑编程通常
我已阅读this article关于Java中不同类型的引用(强引用、软引用、弱引用、幻像引用),但我不太理解。 这些引用类型之间有什么区别?每种类型何时使用? 最佳答案 Java 提供了两种不同类型
我需要一个带有弱键或软键的并发 HashMap ,其中等式是 equals 而不是 ==。 对于此类键,Google Collection 默认选择 ==。 有没有办法覆盖这个选择?我应该如何进行?
我读了here使用下面的命令我们可以在 Linux 系统上模拟硬重启: echo 1 > /proc/sys/kernel/sysrq echo b > /proc/sysrq-trigger 但我想
我正在使用软件 I²C实现读取一组 Sensirion SHT21 传感器。我正在尝试找出一种让传感器回答以查看它们是否实际连接到设备的方法。我正在使用 Arduino,这意味着我所有的代码都是 C/
这个问题在这里已经有了答案: How do you determine using stat() whether a file is a symbolic link? (1 个回答) 关闭 9 年前
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 10 年前。 Improve thi
我一直在使用 ICS 上的 Wifi Direct API,但有点卡住了。 在 API 中,有一个名为 createGroup 的方法可以在手机上创建一个基于遗留软件的接入点。这很棒并且有效,但我似乎
当我在 ruby 中有一个数组时,我可以在其上运行 delete_if block 。问题是它从我的数组中删除了元素。我想要相同的功能,只是不对原始数组进行更改,而是返回一个删除了对象的新数组。
在 Ubuntu Virtualbox 上运行从 Windows 移植的音频应用程序时,它报告以下内容: Devices found: OpenAL Soft OpenAL Soft 40964 in
下面是我的数据库结构的简化版本(在 MVC 2 中构建一个概念验证站点,使用 Entity Framework 4 作为我的 ORM): [Stores] StoreID (PK) StoreName
我用 ESP8266 创建了一个软 AP,我通过 android 6.0 marshmallow mobile 连接到它。连接后,如果我忽略它并打开浏览器窗口打开我的网络服务器页面或使用自定义构建的应
如何应用 Three.js online editor 中所示的 PCF (SOFT) 阴影类型以 JavaScript 代码的形式发送到你的渲染器? 最佳答案 要使用该类型的阴影,您需要使用相应类型
我知道 Wifi Direct 的工作原理是在其中一台设备中创建软 AP(软件接入点)。我也知道很多 Android 支持 Wifi Direct,但 iPhone 不支持。 我的问题是:是否可以创建
我有一个在 14.04.05 LTS 上运行的 Ubuntu 服务器。 此服务器上还安装了几个 ugins mongodb 应用程序。 MongoDB版本为3.4.2 我正在尝试增加 mongodb
我是一名优秀的程序员,十分优秀!