编辑
2024-10-03
graphics
00
请注意,本文编写于 72 天前,最后修改于 67 天前,其中某些信息可能已经过时。

目录

Part 1. Accelerate with Octree.
1.1 Baseline
1.2 Sort distance
Part 2.
Part 2.1 Monte Carlo Sampling
Tent sample
Disk
Sphere
Hemisphere
Himesphere(cos)
Beckmann
Part 2.2 Two simple rendering algorithms
Point lights
Ambient occlusion
Image Based Lighting
Part 3

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.

Part 1. Accelerate with Octree.

1.1 Baseline

Without octree, it will take over 7 hours on rendering one frame with single object(My cpu: AMD 7800X3D).

Without octree:

slow

1.2 Sort distance

It will 100 times faster than before.

With octree:

fast

Result screenshot:

Part 2.

Part 2.1 Monte Carlo Sampling

Tent sample

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()); }

tent

Disk

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; }

Disk

Sphere

Sphere

Hemisphere

Hemisphere

Himesphere(cos)

Himesphere(cos)

Beckmann

image.png

Part 2.2 Two simple rendering algorithms

Point lights

ajax-simple.png

Ambient occlusion

ajax-ao.png

Image Based Lighting

TODO.

Part 3

references:

蒙特卡洛方法与 MCMC 采样

Zhihu Nori Posts

如果对你有用的话,可以打赏哦
打赏
ali pay
wechat pay

本文作者:xmmmmmovo

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 许可协议。转载请注明出处!