《Ray Tracing Gems》 学习笔记 (第二章)

本文深入剖析了光线追踪中光线的数学描述,包括使用参数化表示法定义光线,以及光线间隔的概念。通过DirectX Raytracing (DXR) API的示例,阐述了光线在光线追踪中的定义,强调了光线原点、方向和间隔的重要性。同时,对比了DXR与其他光线追踪系统的差异,如OptiX中的光线类型定义。
摘要由CSDN通过智能技术生成

Chapter 2 : what is a Ray?

上一章,我们理解了什么是光线投影(ray casting)和光线追踪(ray tracing)。这章节我们细致来看什么是光线。

ABSTRACT

We define a ray, show how to use ray intervals, and demonstrate how to specify a ray using DirectX Raytracing (DXR).
在本节中,我们会定义一条光线,展示了如何使用光线间隔(ray intervals),并演示了如何使用DirectX光线跟踪(DXR)来指定一个光线。

2.1 MATHEMATICAL DESCRIPTION OF A RAY

For ray tracing, an important computational construct is a three-dimensional ray. In both mathematics and ray tracing, a ray usually refers to a three-dimensional half-line. A ray is usually specified as an interval on a line. There is no implicit equation for a line in three dimensions analogous to the two-dimensional line y = mx + b, so usually the parametric form is used. In this chapter, all lines, points, and vectors are assumed to be three-dimensional.
对于光线追踪,一个重要的计算结构就是三维光线(3D ray)。 不管是在数学还是在光线追踪中,光线通常是指三维半线(half-line)(射线?)。一条光线通常会被指定为在一条直线(line)上的一部分(interval)。对于一条直线,在三维空间中很难找到一个类似二维空间中 y = m x + b y=mx+b y=mx+b这样的直线方程来隐式表示。因此,通常使用参数化形式来表示。在本章中,所有的直线、点和矢量均假定为三维空间中。

A parametric line can be represented as a weighted average of points A and B:
一条参数化表示的线可以记为点A和B的加权平均值:
P ( t ) = ( 1 − t ) A + t B P(t)=(1-t)A+tB P(t)=(1t)A+tB

In programming, we might think of this representation as a function P(t) that takes a real number t as input and returns a point P. For the full line, the parameter can take any real value, i.e., t ∈ [−∞, +∞], and the point P moves continuously along the line as t changes, as shown in Figure 2-1. To implement this function, we need a way to represent points A and B. These can use any coordinate system, but Cartesian coordinates are almost always used. In APIs and programming languages, this representation is often called a vec3 or float3 and contains three real numbers x, y, and z. The same line can be represented with any two distinct points along the line. However, choosing different points changes the location defined by a given t-value.
在实际编程中,我们会将这种表示形式视为函数 P ( t ) P(t) P(t),该函数以实数 t t t作为输入并返回点 P P P。对于一个完整的直线,参数可以取任何实数,即 t ∈ [ − ∞ , + ∞ ] t∈[-∞,+∞] t[+]。点P随着 t t t的变化而沿直线连续移动,如图2-1所示
。 要实现这个思路,我们需要一种方式来表示点A和B。这里可以使用任何坐标系,但我们常用笛卡尔坐标系(Cartesian coordinates)。 在API和编程语言中,这种表示形式通常被称为vec3float3,其中包含三个实数 x x x y y y z z z。同一条线可以用沿线的任意两个不同的点表示。但是,选择不同的点会更改由给定 t t t值定义的位置。

在这里插入图片描述
It is common to use a point and a direction vector rather than two points. As visualized in Figure 2-2, we can choose our ray direction d as B − A and our ray origin O as point A, giving
但更常见的做法是使用一个点和一个方向向量而非两个点。 如图2-2所示,我们可以将射线方向d选择为B − A,将射线原点O选择为A点,得出
P 9 ( t ) = O + t d P9(t)=O+td

《实时光线追踪渲染精粹》 渲染器使用两种方法来确定像素颜色:光栅化或光线追踪。 光栅化从一个特定像素开始,并询问“这个像素应该是什么颜色?”; 光线追踪则在视角和光源起作用,并询问:“光线在做什么?” 光线追踪的工作原理是:追踪光线在场景内的反射路径。光线每次反射的时候,它都会通过沉积早前对象的颜色来模拟现实生活中的光线,同时损失强度。对于特定类型的材料与效果而言,这种颜色的沉积使得清晰的反射,以及细微,逼真的颜色变化只能通过光线追踪来实现。 由于它模仿光线的真实行为,光线追踪同时擅长于产生区域阴影和环境遮挡。 相反,光栅化比光线追踪更快,成本更低,只是通过一些近似值计算照明。Unreal的光栅化技术在一枚高速GPU上以毫秒为单位提供4K分辨率帧。栅格化可以非常逼近照片级别真实感,同时不一定是物理上精确。另外对于大多数Unreal引擎的用户来说,速度的提升显得非常值得。 但对于更强调照片级真实感而非性能的真人实景电影和建筑可视化项目而言,光线追踪则显得更有优势。到目前为止,由于其巨大的计算需求,光线追踪仅在离线渲染中实施。使用光线追踪计算的场景可能需要几分钟到几个小时才能计算出一个帧,而电影动画的一秒需要24帧才能填充完成。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值