0.1.1 |
|
---|---|
0.1.0 |
|
#11 in #路径追踪
115KB
2.5K SLoC
Spuristo是一个基于CPU的多线程渲染引擎。制作目的是学习Rust和基于物理的渲染 :) 渲染器设计得尽可能模块化,以便于添加新功能或算法。
功能
- 区域光采样
- 带有下一事件估计的路径追踪
- 具有多个重要性采样和GGX分布的微facet BSDF
- 迪士尼漫反射BRDF,Frostbite中使用能量归一化
- 从.OBJ文件解析顶点和法线
- 处理包含高达500万个三角形的网格,渲染时间合理的kd-tree
- 色调映射
- Perlin噪声生成器
用法
克隆存储库后,examples/
文件夹包含场景。要运行 hello_sphere.rs
示例,请执行以下命令
cargo run --example hello_sphere
渲染器可以通过其setter方法或部分通过CLI进行配置
Usage: hello_sphere [-s <samples>] [-t <threads>] [-w <width>] [-h <height>] [-d]
Optional CLI configuration of renderer. Renderer setter methods have priority.
Options:
-s, --samples number of samples per pixel (defaults to 1)
-t, --threads number of threads used (defaults to all)
-w, --width width of the rendered image (defaults to 1000)
-h, --height height of the rendered image (defaults to 1000)
-d, --direct use direct light integrator instead of path tracing.
--help display usage information
使用API
hello_sphere.rs
示例编写如下
use spuristo::*;
use spuristo::tracer::*;
use glam::DVec3;
fn main() -> Result<(), png::EncodingError> {
let camera = Camera::default();
let mut scene = Scene::default();
scene.add(
Plane::new(
DVec3::NEG_Y,
DVec3::Y,
Material::diffuse(Texture::Solid(srgb_to_linear(190, 200, 210)))
)
);
scene.add(
Sphere::new(
8.0 * DVec3::Y + 1.5 * DVec3::NEG_Z,
4.0,
Material::Light(Texture::Solid(srgb_to_linear(255, 255, 255)))
)
);
scene.add(
Sphere::new(
DVec3::ZERO,
1.0,
Material::diffuse(Texture::Solid(srgb_to_linear(0, 0, 255)))
)
.scale(0.3, 0.3, 0.3)
.translate(0.0, -0.7, -1.5)
);
let mut renderer = Renderer::new(scene, camera);
renderer.set_samples(36);
renderer.render()
.save("hello.png")
}
它渲染了一个蓝色球体的图像:
待办事项/WIP
- 最终确定透明微facet材料的折射
- 各向同性介质(雾、烟雾、云...)
- 路径追踪器中的多次重要性采样
- 从微facet中可见法线分布中进行采样
- (纹理映射)
- (双向路径追踪)
- (次表面散射)
参考资料
画廊
![]() |
---|
斯坦福龙的三角形数为871K。使用Intel Xeon Gold 6248的30个线程在45分钟内渲染。每像素1024个样本。 |
![]() |
---|
显示反射和折射的Cornell盒子。使用Intel Xeon Gold 6248的30个线程在50分钟内渲染。每像素4096个样本。 |
![]() |
---|
纳菲蒂蒂雕像,三角形数为6.4M。使用Intel Xeon Gold 6248的40个线程在196分钟内渲染。每像素1024个样本。 |
依赖关系
~14–24MB
~414K SLoC