Nori assignments implement write up.
Nori, a educational oriented path tracing renderer. In this project, will implement with path tracing, accelerate structure and many features with pbrt.
Without octree, it will take over 7 hours on rendering one frame with single object(My cpu: AMD 7800X3D).
Without octree:
It will 100 times faster than before.
With octree:
Result screenshot:
c++/**
* @brief 反函数,p(z)
*
* @param z
* @return float
*/
float tent(float z) {
if (z >= 0.0f && z < 0.5f) {
return std::sqrt(2 * z) - 1.0f;
} else if (z >= 0.5f && z <= 1.0f) {
return 1.0f - std::sqrt(2 - 2 * z);
}
return 0.0f;
}
Point2f Warp::squareToTent(const Point2f& sample) {
return sample.unaryExpr([](auto elem) { return tent(elem); });
}
/**
* @brief tent PDF(概率密度函数)
*
* @param t
* @return float
*/
inline float tentPDF(float t) {
auto absf = std::abs(t);
return absf <= 1.0f ? (1.0f - absf) : 0.0f;
}
float Warp::squareToTentPdf(const Point2f& p) {
return tentPDF(p.x()) * tentPDF(p.y());
}
c++Point2f Warp::squareToUniformDisk(const Point2f& sample) {
auto r = std::sqrt(sample.x());
auto phi = 2.0f * M_PI * sample.y();
return {r * std::cos(phi), r * std::sin(phi)};
}
float Warp::squareToUniformDiskPdf(const Point2f& p) {
return (p.squaredNorm() <= 1.0f) ? INV_PI : 0.0f;
}
TODO.
references:
本文作者:xmmmmmovo
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 许可协议。转载请注明出处!