diff --git a/Pictures/chap05/CIE1931xygamutcomparison.pdf b/Pictures/chap05/CIE1931xygamutcomparison.pdf new file mode 100644 index 0000000..588562b Binary files /dev/null and b/Pictures/chap05/CIE1931xygamutcomparison.pdf differ diff --git a/Pictures/chap06/landscape-dof-960x1920.png b/Pictures/chap06/landscape-dof-960x1920.png new file mode 100644 index 0000000..f993076 Binary files /dev/null and b/Pictures/chap06/landscape-dof-960x1920.png differ diff --git a/Pictures/chap06/landscape-dof.jpg b/Pictures/chap06/landscape-dof.jpg new file mode 100644 index 0000000..39a6574 Binary files /dev/null and b/Pictures/chap06/landscape-dof.jpg differ diff --git a/bibliography.bib b/bibliography.bib index 11994f6..7283fd9 100644 --- a/bibliography.bib +++ b/bibliography.bib @@ -4112,4 +4112,12 @@ @incollection{BERTALMIO2020131 author = {Marcelo Bertalmío}, keywords = {Trichromacy, color spaces, color gamuts, brightness, hue, saturation}, abstract = {This chapter deals with colour. There are models that for simple stimuli in controlled environments can predict very accurately the colour appearance of objects, as well as the magnitude of their colour differences. These models were developed and validated for SDR images, and their extension to the HDR case is not straightforward. For the general case of natural images in arbitrary viewing conditions, there are many perceptual phenomena that come into play and no comprehensive vision model that is capable of handling them all in an effective way. As a result, the colour appearance problem remains very much open, and this affects all aspects of colour representation and processing.} +} + + @misc{enwiki:SRGB, + author = {{Wikipedia contributors}}, + title = {SRGB --- {Wikipedia}{,} The Free Encyclopedia}, + year = {2021}, + url = {https://en.wikipedia.org/w/index.php?title=SRGB&oldid=1059659271}, + note = {[Online; accessed 22-December-2021]} } \ No newline at end of file diff --git a/content/chap0301.tex b/content/chap0301.tex index 5d76c32..0027a27 100644 --- a/content/chap0301.tex +++ b/content/chap0301.tex @@ -17,7 +17,7 @@ \section{基本形状接口}\label{sec:基本形状接口} 所有形状都定义在物体的坐标空间中; 例如,所有球体都定义在球心位于原点的坐标系中。 -为了在场景别处放置球体,必须提供描述从物体空间到世界空间映射的变换。 +为了在场景别处放置球体,必须提供描述从\keyindex{物体空间}{object space}{}到世界空间映射的变换。 类\refvar{Shape}{}保存了该变换及其逆。 \refvar{Shape}{}也接收一个布尔参数\refvar{reverseOrientation}{}来 diff --git a/content/chap05.tex b/content/chap05.tex index 5355b4f..bee125d 100644 --- a/content/chap05.tex +++ b/content/chap05.tex @@ -36,6 +36,4 @@ \chapter{颜色和辐射度学}\label{chap:颜色和辐射度学} \input{content/chap0508.tex} -\input{content/chap05ex01.tex} - -{\noindent\hfil$=========$\hfil{\color{red}{施工分割线}}\hfil$=========$\ \ No newline at end of file +\input{content/chap05ex01.tex} \ No newline at end of file diff --git a/content/chap0502.tex b/content/chap0502.tex index 37cefc6..88609b0 100644 --- a/content/chap0502.tex +++ b/content/chap0502.tex @@ -353,7 +353,8 @@ \subsection{RGB颜色}\label{sub:RGB颜色} \end{array}\right]\, . \end{align*} -pbrt中实现的转换例程是基于为高清电视定义的RGB光谱标准集的。 +pbrt中实现的转换例程是基于为高清电视定义的RGB光谱标准集的 +\sidenote{译者注:这些系数的来由可见译者补充的\refsub{色度学}。}。 \begin{lstlisting} `\refcode{Spectrum Utility Declarations}{+=}\lastnext{SpectrumUtilityDeclarations}` inline void `\initvar{XYZToRGB}{}`(const `\refvar{Float}{}` xyz[3], `\refvar{Float}{}` rgb[3]) { diff --git a/content/chap05ex01.tex b/content/chap05ex01.tex index 926e5b0..c507a94 100644 --- a/content/chap05ex01.tex +++ b/content/chap05ex01.tex @@ -2,7 +2,7 @@ \section{译者补充:辐射度学、光度学与色度学}\label{sec:译者 \begin{remark} 本节内容不是原书内容,而是译者根据有关资料\citep{978-7-5640-0658-7, - wiki:solidangle,GB3102.6-93,enwiki:1052681830, + wiki:solidangle,GB3102.6-93,enwiki:1052681830,enwiki:SRGB, wiki:candela,Hoffmann2015,wiki:eye,BERTALMIO2020131}补充的,请酌情参考和斧正。 \end{remark} @@ -248,7 +248,7 @@ \subsection{光度学}\label{sub:光度学} \keyindex{光亮度}{luminance}{}与辐射亮度对应,单位为cd$/$m$^2$。 \subsection{色度学}\label{sub:色度学} -\keyindex{色度学}{colorimetry}{}在物理上量化描述人类颜色知觉的科学技术。 +\keyindex{色度学}{colorimetry}{}是在物理上量化描述人类颜色知觉的科学技术。 \subsubsection*{人眼视觉特性与颜色视觉理论} 人眼(\reffig{5.ex04})中负责感光的部分是\keyindex{视网膜}{retina}{}, 其中具有两种\keyindex{感光细胞}{photoreceptor cell}{}, @@ -296,10 +296,10 @@ \subsubsection*{颜色匹配} \end{figure} 1853年,德国学者格拉斯曼(Hermann Günther Gra{\ss}mann)总结出加色混合的性质, -即\keyindex{格拉斯曼定律}{Grassmann's laws}{},为现代色度学的奠定了基础。 +即格拉斯曼定律,为现代色度学奠定了基础。 \begin{proposition} - 格拉斯曼定律的现代解释有四点内容: + \keyindex{格拉斯曼定律}{Grassmann's laws}{}的现代解释有四点内容: \begin{enumerate} \item 人的视觉只能分辨颜色的三种变化(例如明度、色调、饱和度)。 \item 在由两种成分组成的混合色光中,若一种成分连续变化,则混合色光外观也连续变化。 @@ -356,7 +356,7 @@ \subsubsection*{颜色匹配} 若分别以$\compcolor{C},\compcolor{R},\compcolor{G},\compcolor{B}$表示 被匹配的颜色以及红、绿、蓝三原色光的单位,以实数$C,R,G,B$表示相应颜色的数量, 则颜色匹配方程可写作 -\begin{align} +\begin{align}\label{eq:colormatchrgb} C\compcolor{C}\equiv R\compcolor{R}+G\compcolor{G}+B\compcolor{B}\, , \end{align} 其中符号“$\equiv$”表示颜色外观相同,$R,G,B$可以为负,$C=R+G+B$。 @@ -491,8 +491,8 @@ \subsubsection*{CIE 1931颜色空间} 即\keyindex{CIE 1931 XYZ 颜色空间}{CIE 1931 XYZ color space}{}。 注意$\compcolor{X},\compcolor{Y},\compcolor{Z}$是现实中观察不到的理论假想色。 在该颜色空间中,颜色匹配方程为 -\begin{align} - \compcolor{C}\equiv X\compcolor{X}+Y\compcolor{Y}+Z\compcolor{Z}\, . +\begin{align}\label{eq:colormatchxyz} + C\compcolor{C}\equiv X\compcolor{X}+Y\compcolor{Y}+Z\compcolor{Z}\, . \end{align} 其中$X,Y,Z$为相应的三刺激值。 依据构建过程中考虑的第1点问题,$Y$的光谱分布就是光谱光视效率函数,即 @@ -521,9 +521,20 @@ \subsubsection*{CIE 1931颜色空间} \caption{CIE XYZ颜色匹配函数($2^{\circ}$视场),数据来源于\protect\url{http://www.cvrl.org}。} \label{fig:5.ex10} \end{figure} + +类似于RGB,对于光谱分布为$S(\lambda)$的光刺激,相应的XYZ值通过在颜色匹配函数上积分算得: +\begin{align} + X & =k\int \bar{x}(\lambda)S(\lambda)\mathrm{d}\lambda\, , \\ + Y & =k\int \bar{y}(\lambda)S(\lambda)\mathrm{d}\lambda\, , \\ + Z & =k\int \bar{z}(\lambda)S(\lambda)\mathrm{d}\lambda\, , +\end{align} +其中$k$为适当的规范化系数。 + \begin{figure}[htbp] - \centering\includegraphics[width=0.75\linewidth]{chap05/CIE1931xyCIERGB.pdf} - \caption{CIE 1931 XYZ颜色空间色品图。图中的三角形标出了CIE RGB三原色的位置。} + \centering\includegraphics[width=0.6\linewidth]{chap05/CIE1931xyCIERGB.pdf} + \caption{CIE 1931 XYZ颜色空间色品图。图中的三角形标出了CIE RGB三原色的位置。 + 注意因为当下显示和打印设备的色域均不能覆盖整个颜色空间,加之图片格式的限制, + 所以该图中的一部分颜色一定会显示得不准确。} \label{fig:5.ex11} \end{figure} @@ -532,8 +543,165 @@ \subsubsection*{CIE 1931颜色空间} 截取平面$X+Y+Z=1$再向$XY$平面投影的结果(\reffig{5.ex12})。 \begin{figure}[htbp] \centering\includegraphics[width=0.5\linewidth]{chap05/Projectionandchromaticityplane.pdf} + \put(-80,38){\color{white}$X$} + \put(-165,130){\color{white}$Y$} + \put(-160,4){\color{white}$Z$} \caption{XYZ体与$xy$色品图。左图是XYZ体,右上是截平面$X+Y+Z=1$, 右下是将截平面投影到$XY$平面得到的$xy$色品图。图示来自\protect\citet{BERTALMIO2020131}。} \label{fig:5.ex12} \end{figure} +\subsubsection*{颜色空间的转化} +由于选择的三原色以及三刺激值单位不同,出现了多种颜色空间。 +这里我们介绍RGB与XYZ颜色空间相互转化的推导过程。 + +以XYZ转化到RGB空间为例。XYZ为旧空间,RGB为新空间。 +设新空间的三原色$\compcolor{R},\compcolor{G},\compcolor{B}$在 +旧空间中的三刺激值为$X_i,Y_i,Z_i,(i=\mathrm{r},\mathrm{g},\mathrm{b})$,即 +\begin{align}\label{eq:colorbasis} + \compcolor{R} & =X_\mathrm{r}\compcolor{X}+Y_\mathrm{r}\compcolor{Y}+Z_\mathrm{r}\compcolor{Z}\, , \\ + \compcolor{G} & =X_\mathrm{g}\compcolor{X}+Y_\mathrm{g}\compcolor{Y}+Z_\mathrm{g}\compcolor{Z}\, , \\ + \compcolor{B} & =X_\mathrm{b}\compcolor{X}+Y_\mathrm{b}\compcolor{Y}+Z_\mathrm{b}\compcolor{Z}\, . +\end{align} +对照颜色匹配方程\refeq{colormatchrgb}与\refeq{colormatchxyz},可得 +\begin{align} + X\compcolor{X}+Y\compcolor{Y}+Z\compcolor{Z}=R\compcolor{R}+G\compcolor{G}+B\compcolor{B}\, . +\end{align} +联立以上式子,由对应系数相等整理可得 +\begin{align} + \left[\begin{array}{c} + X \\Y\\Z + \end{array}\right]= + \left[\begin{array}{ccc} + X_\mathrm{r} & X_\mathrm{g} & X_\mathrm{b} \\ + Y_\mathrm{r} & Y_\mathrm{g} & Y_\mathrm{b} \\ + Z_\mathrm{r} & Z_\mathrm{g} & Z_\mathrm{b} + \end{array}\right] + \left[\begin{array}{c} + R \\G\\B + \end{array}\right]\, . +\end{align} +上式表明两种颜色空间是线性转换关系,只要知道九个系数$X_i,Y_i,Z_i,(i=\mathrm{r},\mathrm{g},\mathrm{b})$即可。 +实际中更常见的是这些系数待定,但知道对应的色品坐标$x_i,y_i,z_i,(i=\mathrm{r},\mathrm{g},\mathrm{b})$。设 +\begin{align} + C_i=X_i+Y_i+Z_i\, ,\quad (i=\mathrm{r},\mathrm{g},\mathrm{b})\, , +\end{align} +则有 +\begin{align}\quad + X_i=C_ix_i\, ,\quad Y_i=C_iy_i\, ,\quad Z_i=C_iz_i\, ,\quad (i=\mathrm{r},\mathrm{g},\mathrm{b})\, . +\end{align} +记 +\begin{align} + P & =\left[\begin{array}{ccc} + x_\mathrm{r} & x_\mathrm{g} & x_\mathrm{b} \\ + y_\mathrm{r} & y_\mathrm{g} & y_\mathrm{b} \\ + z_\mathrm{r} & z_\mathrm{g} & z_\mathrm{b} + \end{array}\right]\, , \\ + D & =\left[\begin{array}{ccc} + C_\mathrm{r} & & \\ + & C_\mathrm{g} & \\ + & & C_\mathrm{b} + \end{array}\right]\, , +\end{align} +于是 +\begin{align} + [X\quad Y\quad Z]^{\mathrm{T}}=PD[R\quad G\quad B]^{\mathrm{T}}\, . +\end{align} +其中矩阵$P$是已知的,还需确定$D$中的三个系数$C_i$, +一般我们通过选择一种颜色(例如参照白) +在旧空间的三刺激值$X_0,Y_0,Z_0$以及规定它在新空间的三刺激值$R_0,G_0,B_0$来求解,即 +\begin{align} + [X_0\quad Y_0\quad Z_0]^{\mathrm{T}}=PD[R_0\quad G_0\quad B_0]^{\mathrm{T}}\, . +\end{align} +可解得 +\begin{align} + \left[\begin{array}{c} + C_\mathrm{r} \\C_\mathrm{g}\\C_\mathrm{b} + \end{array}\right]=\left(P + \left[\begin{array}{ccc} + R_0 & & \\ + & G_0 & \\ + & & B_0 + \end{array}\right]\right)^{-1} + \left[\begin{array}{c} + X_0 \\Y_0\\Z_0 + \end{array}\right]\, . +\end{align} +此时转化关系得以完全确定。还可得逆转化关系相应为 +\begin{align} + [R\quad G\quad B]^{\mathrm{T}}=(PD)^{-1}[X\quad Y\quad Z]^{\mathrm{T}}\, . +\end{align} + +对于CIE 1931 RGB颜色空间与XYZ空间的转化,以等能白光为参照取 +\begin{align} + \begin{array}{lll} + x_\mathrm{r}=0.73467\, , & x_\mathrm{g}=0.27376\, , & x_\mathrm{b}=0.16658\, , \\ + y_\mathrm{r}=0.26533\, , & y_\mathrm{g}=0.71741\, , & y_\mathrm{b}=0.00886\, , \\ + X_0=Y_0=Z_0=1\, , & R_0=G_0=B_0=1\, . & + \end{array} +\end{align} +算得 +\begin{align} + PD & =\left[\begin{array}{rrr} + 0.4900 & 0.3100 & 0.2000 \\ + 0.1770 & 0.8124 & 0.0106 \\ + -0.0000 & 0.0100 & 0.9900 + \end{array}\right]\, , \\ + (PD)^{-1} & =\left[\begin{array}{rrr} + 2.3647 & -0.8966 & -0.4681 \\ + -0.5152 & 1.4264 & 0.0887 \\ + 0.0052 & -0.0144 & 1.0092 + \end{array}\right]\, . +\end{align} + +\keyindex{sRGB颜色空间}{standard RGB color space}{}是惠普与微软等企业 +于1996年共同开发的用于显示器、打印机以及互联网的一种色域标准。 +对于sRGB的线性值与XYZ空间的转化,以D65为参照白\sidenote{D65是CIE规定的标准日光光源,色温约6500{\normalfont K}。}取 +\begin{align} + \begin{array}{lll} + x_\mathrm{r}=0.6400\, , & x_\mathrm{g}=0.3000\, , & x_\mathrm{b}=0.1500\, , \\ + y_\mathrm{r}=0.3300\, , & y_\mathrm{g}=0.6000\, , & y_\mathrm{b}=0.0600\, , \\ + x_0=0.3127\, , & y_0=0.3290\, , & Y_0=1.0000\, , \\ + R_0=G_0=B_0=1\, . & & + \end{array} +\end{align} +算得 +\begin{align} + PD & =\left[\begin{array}{rrr} + 0.4124 & 0.3576 & 0.1805 \\ + 0.2126 & 0.7152 & 0.0722 \\ + 0.0193 & 0.1192 & 0.9505 + \end{array}\right]\, , \\ + (PD)^{-1} & =\left[\begin{array}{rrr} + 3.2410 & -1.5374 & -0.4986 \\ + -0.9692 & 1.8760 & 0.0416 \\ + 0.0556 & -0.2040 & 1.0570 + \end{array}\right]\, . +\end{align} + +sRGB在完成RGB线性值(在0到1之间)的计算后,还要进行非线性的伽马校正才得到最终结果。 +对于线性值$C(=R,G,B)$,相应最终值为 +\begin{align} + C_{\text{sRGB}}=\left\{ + \begin{array}{ll} + \displaystyle12.92C\, , & \text{若}C\le0.0031308\, , \\ + \displaystyle1.055C^{\frac{1}{2.4}}-0.055\, , & \text{其他}\, . + \end{array} + \right. +\end{align} +由最终值到线性值的逆变换为 +\begin{align} + C=\left\{ + \begin{array}{ll} + \displaystyle\frac{C_{\text{sRGB}}}{12.92}\, , & \text{若}C_{\text{sRGB}}\le0.04045\, , \\ + \displaystyle\left(\frac{C_{\text{sRGB}}+0.055}{1.055}\right)^{2.4}\, , & \text{其他}\, . + \end{array} + \right. +\end{align} + +\reffig{5.ex13}展示了多种\keyindex{色域}{color gamut}{}标准。 +\begin{figure}[htbp] + \centering\includegraphics[width=0.6\linewidth]{chap05/CIE1931xygamutcomparison.pdf} + \caption{一些RGB与CMYK色域在CIE 1931 $xy$色品图中的范围。} + \label{fig:5.ex13} +\end{figure} \ No newline at end of file diff --git a/content/chap06.tex b/content/chap06.tex index 5a650fd..1e3e46c 100644 --- a/content/chap06.tex +++ b/content/chap06.tex @@ -1,5 +1,36 @@ +\chapterimage{Pictures/chap06/landscape-dof-960x1920.png} \chapter{相机模型}\label{chap:相机模型} +\setcounter{sidenote}{1} + +在第\refchap{绪论}中,我们介绍了计算机图形学中常用的针孔相机模型。 +该模型很容易描述和模拟,但它忽略了真实相机中透镜对于穿过的光线具有的重要效应。 +例如,针孔相机渲染的所有东西都是清晰对焦的——真实透镜系统不可能达到这种状态。 +这样的图像常常看得出来是计算机生成的。 +更一般地,离开透镜系统的辐射分布和进入它的分布有很大区别; +对透镜的这种效应建模对于准确模拟成像的辐射度量非常重要。 + +相机透镜系统也会引入各种影响其所构建图像的\keyindex{像差}{aberration}{}; +例如,因为能到达胶片或传感器边缘的光比中心处更少, +\keyindex{暗角}{vignetting}{}\sidenote{译者注:也称晕影。}导致图像边缘变暗。 +透镜也可以造成\keyindex{枕状畸变}{pincushion distortion}{distortion畸变}或\keyindex{桶状畸变}{barrel distortion}{distortion畸变}, +即让直线成像为曲线。 +尽管透镜设计者尽力在其设计中最小化像差,但它们仍可对图像有明显作用。 + +像第\refchap{形状}的\refvar{Shape}{}那样,pbrt中的相机也表示为抽象基类。 +本章介绍类\refvar{Camera}{}及其两个关键方法\refvar[GenerateRay]{Camera::GenerateRay}{()} +和\refvar[GenerateRayDifferential]{Camera::GenerateRayDifferential}{()}。 +第一个方法计算对应于胶片平面上样本位置的世界空间光线。 +通过基于不同成像模型的不同方法生成这些光线,pbrt中的相机可以创建同一3D场景的多种图像。 +第二种方法不仅生成该光线还计算采样该光线的图像区域的信息; +例如该信息用于第\refchap{纹理}的抗锯齿计算。 +在\refsub{采样相机2}将介绍一些额外的\refvar{Camera}{}方法以支持双向光传输算法。 + +本章中,我们将展示\refvar{Camera}{}接口的一些实现, +从实现具有一定普遍性的理想针孔模型开始, +到和真实世界相机一样能模拟光穿过一组玻璃透镜元件成像的逼真模型结束。 \input{content/chap0601.tex} -\input{content/chap0604.tex} \ No newline at end of file +\input{content/chap0604.tex} + +{\noindent\hfil$=========$\hfil{\color{red}{施工分割线}}\hfil$=========$\ \ No newline at end of file diff --git a/content/chap0601.tex b/content/chap0601.tex index 894e044..3385fcc 100644 --- a/content/chap0601.tex +++ b/content/chap0601.tex @@ -1,38 +1,35 @@ \section{相机模型}\label{sec:相机模型} -抽象的Camera基类持有通用的相机选项并定义了所有相机实现必须提供的接口。它被定义在core/camera.h和core/camera.cpp文件中。 +抽象基类\refvar{Camera}{}持有通用的相机选项并定义了所有相机实现必须提供的接口。 +它被定义在文件\href{https://github.com/mmp/pbrt-v3/tree/master/src/core/camera.h}{\ttfamily core/camera.h} +和\href{https://github.com/mmp/pbrt-v3/blob/master/src/core/camera.cpp}{\ttfamily core/camera.cpp}中。 \begin{lstlisting} `\initcode{Camera Declarations}{=}\initnext{CameraDeclarations}` class `\initvar{Camera}{}` { public: `\refcode{Camera Interface}{}` - Camera(const AnimatedTransform &CameraToWorld, Float shutterOpen, Float shutterClose, Film *film, const Medium *medium); - virtual ~Camera(); - virtual Float GenerateRay(const CameraSample &sample, Ray *ray) const = 0; - virtual Float GenerateRayDifferential(const CameraSample &sample, RayDifferential *rd) const; - virtual Spectrum We(const Ray &ray, Point2f *pRaster2 = nullptr) const; - virtual void Pdf_We(const Ray &ray, Float *pdfPos, Float *pdfDir) const; - virtual Spectrum Sample_Wi(const Interaction &ref, const Point2f &u, Vector3f *wi, Float *pdf, Point2f *pRaster, VisibilityTester *vis) const; `\refcode{Camera Public Data}{}` - AnimatedTransform CameraToWorld; - const Float shutterOpen, shutterClose; - Film *film; - const Medium *medium; }; - \end{lstlisting} -基类\refvar{Camera}{}的构造函数需要传入几个适合所有相机类型的参数。 -其中最重要的是将摄像机置于场景中的Transform,它被存储在CameraToWorld成员变量中。 -需要注意的是其类型为AnimatedTransform(而不仅仅是一个普通的Transform),这样相机本身就可以随着时间的推移而移动。 -现实生活中的物理相机有一个快门,当我们按动快门按钮的时候相机内部的快门将在短时间内打开,使胶片曝光。 -这个非零曝光时间的一个结果是\keyindex{动态模糊}{motion blur}{}:在曝光期间相对于相机处于运动状态的物体会被模糊化。 -因此,所有Camera的子类都要求储存一个快门打开和快门关闭的时间,并负责生成具有相关时间的光线,以便对场景进行采样。 -这样\refvar{Camera}{}就可以基于快门打开时间和快门关闭时间之间光线时间的适当分布,计算出表现出动态模糊的图像。 +基类\refvar{Camera}{}的构造函数接收几个适合于所有相机类型的参数。 +其中最重要的是将相机置于场景中的变换,它被存储在成员变量\refvar{CameraToWorld}{}中。 +\refvar{Camera}{}存储了一个\refvar{AnimatedTransform}{}(而不仅仅是一个普通的\refvar{Transform}{}), +这样相机本身就可以随着时间移动。 + +真实世界的相机有一个\keyindex{快门}{shutter}{},它在短时间内打开使胶片曝光。 +这个非零\keyindex{曝光时间}{exposure time}{}的一个结果是\keyindex{运动模糊}{motion blur}{}: +在曝光期间相对于相机运动的物体会被模糊化。 +因此所有\refvar{Camera}{}都储存一个快门打开和快门关闭的时间, +并负责生成具有相关时间的光线,以便对场景进行采样。 +基于快门打开时间和快门关闭时间之间光线时间的适当分布,就能计算表现出运动模糊的图像。 -\refvar{Camera}{}还包含一个指向\refvar{Film}{}类实例的指针,以表示最终图像(\refvar{Film}{}在第7.9节中描述)。 -同时其也储存了一个指向\refvar{Medium}{}实例的指针,以表示摄像机所在的散射介质(\refvar{Medium}{}在第11.3节中描述)。 +\refvar{Camera}{}还包含一个指向类\refvar{Film}{}实例的指针, +以表示最终图像(\refvar{Film}{}在\refsec{胶片与成像管道}中介绍), +以及一个指向\refvar{Medium}{}实例的指针, +以表示相机所在的散射介质(\refvar{Medium}{}在\refsec{介质}中介绍)。 -相机的实现必须将设置这些值的参数传递给相机构造函数。我们在这里只展示构造函数的原型,因为它的实现只是将参数复制到相应的成员变量。 +相机的实现必须将设置这些值的参数传给\refvar{Camera}{}的构造函数。 +我们这里只展示构造函数的原型,因为其实现只是将参数复制到相应的成员变量中。 \begin{lstlisting} `\initcode{Camera Interface}{=}\initnext{CameraInterface}` `\refvar{Camera}{}`(const `\refvar{AnimatedTransform}{}` &CameraToWorld, `\refvar{Float}{}` shutterOpen, @@ -56,14 +53,19 @@ \section{相机模型}\label{sec:相机模型} `\refvar{Ray}{}` *ray) const = 0; \end{lstlisting} -\refvar{CameraSample}{}结构持有指定相机光线所需的所有样本值。 -它的\refvar{pFilm}{}成员给出了生成的光线携带辐射的胶片上的点。 -射线经过的镜头上的点在pLens中(对于包含镜头概念的相机),\refvar[time]{CameraSample::time}{}给出了射线应该对场景进行采样的时间;实现应该使用这个值在shutterOpen-shutterClose时间范围内进行线性插值。 -(仔细选择这些不同的采样值可以极大地提高最终图像的质量;这就是第7章的大部分内容)。 +\refvar{CameraSample}{}结构体持有指定相机光线所需的所有样本值。 +它的成员\refvar{pFilm}{} +给出了携带辐射的生成光线对应的胶片上的点。 +(对于包含镜头概念的相机)光线穿过的镜头上的点在\refvar{pLens}{}中, +\refvar{CameraSample::time}{}给出了光线应该对场景进行采样的时间; +实现应该用该值在\refvar{shutterOpen}{}-\refvar{shutterClose}{}时间范围内进行线性插值。 +(仔细选择这些各种样本值可以极大地提高最终图像的质量;这是第\refchap{采样与重构}的主要内容。) -\refvar[GenerateRay]{GenerateRay}{}()也会返回一个浮点值,这个值会影响沿生成的射线到达胶片平面的辐射对最终图像的贡献程度。 -简单的相机模型可以只返回1,但是模拟真实物理镜头系统的相机,比如第6.4节中的相机,会根据镜头的光学特性来设置这个值,以表示光线在镜头中的携带量。 -(参见第6.4.7节和第13.6.6节,以了解更多关于这个权重到底是如何计算和使用的信息)。 +\refvar{GenerateRay}{()}也会返回一个浮点值, +该值会影响沿生成的光线到达胶片平面的辐射对最终图像的贡献程度。 +简单的相机模型可以直接返回1,但是像\refsec{逼真相机}中模拟真实物理透镜系统的相机 +会根据其光学特性设置该值以表示光线携带了多少光量穿过透镜。 +(参见\refsub{相机测量方程}和\refsub{采样相机1}以了解更多关于如何计算和使用该权重的信息。) \begin{lstlisting} `\refcode{Camera Declarations}{+=}\lastnext{CameraDeclarations}` struct `\initvar{CameraSample}{}` { @@ -72,41 +74,62 @@ \section{相机模型}\label{sec:相机模型} `\refvar{Float}{}` `\initvar[CameraSample::time]{time}{}`; }; \end{lstlisting} -\refvar{GenerateRayDifferential}()方法像\refvar{GenerateRay}{}()一样计算一条主射线,但同时也计算了在胶片平面上向和方向移动一个像素的相应射线。 -这些关于摄像机光线如何随胶片上的位置变化的信息,有助于给系统的其他部分提供一个概念,即某条摄像机光线的样本代表了多少胶片区域,这对与一些抗锯齿的计算特别有用。 + +方法\refvar{GenerateRayDifferential}{()}像\refvar{GenerateRay}{()}一样计算一条主光线, +还计算在胶片平面上向$x$和$y$方向移动一像素的相应光线。 +关于相机光线如何作为胶片上位置的函数并随之变化的信息利于让系统其他部分 +对一特定相机光线样本表示多大胶片面积有一个概念,这对抗锯齿纹理贴图查询特别有用。 \begin{lstlisting} `\initcode{Camera Method Definitions}{=}` `\refvar{Float}{}` `\refvar{Camera}{}`::`\initvar{GenerateRayDifferential}{}`(const `\refvar{CameraSample}{}` &sample, `\refvar{RayDifferential}{}` *rd) const { `\refvar{Float}{}` wt = `\refvar{GenerateRay}{}`(sample, rd); - `\refcode{Find camera ray after shifting one pixel in the $x$ direction}{}` - `\refcode{Find camera ray after shifting one pixel in the $y$ direction}{}` + `\refcode{Find camera ray after shifting one pixel in the x direction}{}` + `\refcode{Find camera ray after shifting one pixel in the y direction}{}` rd->`\refvar{hasDifferentials}{}` = true; return wt; } \end{lstlisting} -找到一个像素以上的射线只是初始化一个新的\refvar{CameraSample}并将调用\refvar{GenerateRay}()返回的适当值复制到RayDifferential结构中。片段<>的实现与此类似,这里不再赘述。 +寻找$x$加一像素对应的光线只需初始化一个新的\refvar{CameraSample}{}并将 +调用\refvar{GenerateRay}{()}返回的适当值复制到结构体\refvar{RayDifferential}{}中。 +代码片\refcode{Find camera ray after shifting one pixel in the y direction}{}的实现类似, +这里不再赘述\sidenote{译者注:我补充回来了。}。 \begin{lstlisting} `\initcode{Find camera ray after shifting one pixel in the x direction}{=}` - `\refvar{CameraSample} sshift = sample; - sshift.\refvar{`\refvar{pFilm}}.x++; - `\refvar{Ray}` rx; - `\refvar{Float}` wtx = `\refvar{GenerateRay}`(sshift, &rx); - if (wtx == 0) return 0; - rd->rxOrigin = rx.o; - rd->rxDirection = rx.d; +`\refvar{CameraSample}{}` sshift = sample; +sshift.`\refvar{pFilm}{}`.x++; +`\refvar{Ray}{}` rx; +`\refvar{Float}{}` wtx = `\refvar{GenerateRay}{}`(sshift, &rx); +if (wtx == 0) return 0; +rd->`\refvar{rxOrigin}{}` = rx.`\refvar[Ray::o]{o}{}`; +rd->`\refvar{rxDirection}{}` = rx.`\refvar[Ray::d]{d}{}`; +\end{lstlisting} +\begin{lstlisting} +`\initcode{Find camera ray after shifting one pixel in the y direction}{=}` +sshift.`\refvar{pFilm}{}`.x--; +sshift.`\refvar{pFilm}{}`.y++; +`\refvar{Ray}{}` ry; +`\refvar{Float}{}` wty = `\refvar{GenerateRay}{}`(sshift, &ry); +if (wty == 0) return 0; +rd->`\refvar{ryOrigin}{}` = ry.`\refvar[Ray::o]{o}{}`; +rd->`\refvar{ryDirection}{}` = ry.`\refvar[Ray::d]{d}{}`; \end{lstlisting} - \subsection{相机坐标空间}\label{sub:相机坐标空间} -我们已经利用了两个重要的建模坐标空间,物体空间和世界空间。我们现在将引入一个额外的坐标空间,即相机空间,它的原点是相机。我们有: - -物体空间。这是定义几何基元的坐标系统。例如,pbrt中的球体被定义为以其对象空间的原点为中心。 - -世界空间。虽然每个图元都可能有自己的对象空间,但场景中的所有物体都是相对于一个单一的世界空间放置的。 -每个图元都有一个对象到世界的转换,决定了它在世界空间中的位置。世界空间是标准框架,所有其它空间都是据此定义的。 - -相机空间。在场景中的某个世界空间点上放置一个摄像机,并有一个特定的观察方向和方向。这个摄像机定义了一个新的坐标系,其原点在摄像机的位置。 -这个坐标系的z轴被映射到观察方向,而轴被映射到上升方向。这是一个方便的空间,用于推理哪些物体有可能被摄像机看到。 -例如,如果一个物体的摄像机空间边界框完全在 z=0 平面后面(而且摄像机的视野不超过180度),那么这个物体对摄像机来说就不可见。 \ No newline at end of file +我们已经利用了两个重要的建模坐标空间,物体空间和世界空间。 +我们现在将引入一个额外的坐标空间,即\keyindex{相机空间}{camera space}{},相机位于其原点。我们有: +\begin{itemize} + \item \keyindex{物体空间}{object space}{}:这是定义几何图元的坐标系统。 + 例如,pbrt中的球体定义为以其物体空间原点为中心。 + \item \keyindex{世界空间}{world space}{}:虽然每个图元都可能有自己的物体空间, + 但场景中的所有物体都是相对于一个单一的世界空间放置的。 + 每个图元都有一个决定其在世界空间中位于何处的物体到世界的变换。 + 世界空间是定义所有其他空间所依据的标准坐标系。 + \item \keyindex{相机空间}{camera space}{}:在场景中的某个世界空间点上放置一个摄像机, + 并有特定的观察方向和朝向。该相机定义了一个新的坐标系,其原点在相机的位置。 + 该坐标系的$z$轴映射为观察方向,而$y$轴映射为向上方向。 + 这是个便于推断哪些物体可能对相机可见的空间。 + 例如,如果一个物体的相机空间边界框完全在$z=0$平面之后 + (且相机的视野不宽于180度),则该物体对相机就不可见。 +\end{itemize} \ No newline at end of file diff --git a/content/chap0604.tex b/content/chap0604.tex index ed4a5ac..441fa3a 100644 --- a/content/chap0604.tex +++ b/content/chap0604.tex @@ -1 +1,3 @@ -\section{逼真相机}\label{sec:逼真相机} \ No newline at end of file +\section{逼真相机}\label{sec:逼真相机} + +\subsection{相机测量方程}\label{sub:相机测量方程} \ No newline at end of file diff --git a/content/chap1306.tex b/content/chap1306.tex index e17664d..087a4ea 100644 --- a/content/chap1306.tex +++ b/content/chap1306.tex @@ -1,3 +1,5 @@ \section{2D采样的多维变换}\label{sec:2D采样的多维变换} -\subsection{采样单位圆盘}\label{sub:采样单位圆盘} \ No newline at end of file +\subsection{采样单位圆盘}\label{sub:采样单位圆盘} + +\subsection{采样相机}\label{sub:采样相机1} \ No newline at end of file diff --git a/content/chap1601.tex b/content/chap1601.tex index 8172d9a..d96d2a6 100644 --- a/content/chap1601.tex +++ b/content/chap1601.tex @@ -1,5 +1,6 @@ \section{路径-空间测量方程}\label{sec:路径-空间测量方程} +\subsection{采样相机}\label{sub:采样相机2} \subsection{非对称散射}\label{sub:非对称散射} \begin{lstlisting} `\initcode{TransportMode Declarations}{=}`