Dandelion 1.1.2
A light-weight 3D builder for educational usage
载入中...
搜索中...
未找到
WhittedRenderer类 参考

实现 Whitted-Style 光线追踪管线。 更多...

#include <render_engine.h>

Public 成员函数

 WhittedRenderer (RenderEngine &engine)
void render (Scene &scene)

Public 属性

float & width
float & height
int & n_threads
bool use_bvh
std::vector< unsigned char > & rendering_res

静态 Public 属性

static constexpr float mirror_threshold = 1000.0f

Private 成员函数

float fresnel (const Eigen::Vector3f &I, const Eigen::Vector3f &N, const float &ior)
 菲涅尔方程根据观察角度计算反射光线的所占百分比
std::optional< std::tuple< Intersection, GL::Material > > trace (const Ray &ray, const Scene &scene)
 追踪光线与场景中物体的相交情况
Eigen::Vector3f cast_ray (const Ray &ray, const Scene &scene, int depth)
 追踪指定光线得到颜色

Private 属性

std::shared_ptr< spdlog::logger > logger

详细描述

实现 Whitted-Style 光线追踪管线。

成员函数说明

◆ cast_ray()

Vector3f WhittedRenderer::cast_ray ( const Ray & ray,
const Scene & scene,
int depth )
private

追踪指定光线得到颜色

参数
ray当前追踪的光线
scene当前渲染的场景
depth最大反射次数

◆ fresnel()

float WhittedRenderer::fresnel ( const Eigen::Vector3f & I,
const Eigen::Vector3f & N,
const float & ior )
private

菲涅尔方程根据观察角度计算反射光线的所占百分比

参数
I入射光方向
N法线向量
ior当前反射介质的折射率

◆ render()

void WhittedRenderer::render ( Scene & scene)

whitted-style 渲染器的渲染调用接口

◆ trace()

std::optional< std::tuple< Intersection, GL::Material > > WhittedRenderer::trace ( const Ray & ray,
const Scene & scene )
private

追踪光线与场景中物体的相交情况

遍历场景中的所有物体,找到与光线最近的相交点,并返回相交信息和物体材质信息; 根据use_bvh决定是否使用 BVH 进行加速求交

参数
ray待检测的光线
scene当前渲染的场景
返回
如果相交,返回包含相交信息和物体材质的元组;如果不相交,返回std::nullopt

类成员变量说明

◆ mirror_threshold

float WhittedRenderer::mirror_threshold = 1000.0f
staticconstexpr

镜面反射的阈值

◆ use_bvh

bool WhittedRenderer::use_bvh

是否使用 BVH 进行加速


该类的文档由以下文件生成: