A punctual light is not one that is on time for its appointments, but rather a light that has a location, unlike directional lights.Such lights also have no dimensions to them,no shape or size, unlike real-world light sources.

精准光不是准时赴约的灯,而是有位置的灯,不像定向灯。这种灯也没有尺寸,没有形状或大小,不像现实世界的光源。

We use the term “punctual,” from the Latin punctus meaning “point,” for the class consisting of all sources of illumination that originate from a single, local position. We use the term “point light” to mean a specific kind of emitter, one that shines light equally in all directions. So, point and spotlight are two different forms of punctual lights.

我们用“精准”这个词来表示所有的照明来源都来自于一个单一的、局部的位置,这个词来自拉丁语puntus,意思是“点”。我们用“点光”这个词来表示一种特定的发射器,一种可以向所有方向均匀发光的发射器。所以,点和聚光灯是准时灯的两种不同形式。

The light direction vector l varies depending on the location of the currently shaded surface point p0 relative to the punctual light’s position plight:

灯光方向向量l根据当前着色表面点p0相对于点光源位置的位置而变化:

This equation is an example of vector normalization: dividing a vector by its length to produce a unit-length vector pointing in the same direction.

这个等式是向量归一化的一个例子:用向量除以它的长度,得到一个指向同一方向的单位长度向量。

This is another common shading operation, and, like the shading operations we have seen in the previous section, it is a built-in function in most shading languages.

这是另一种常见的着色操作,就像我们在上一节中看到的着色操作一样,它是大多数着色语言中的内置函数。

Applying this to the punctual light direction computation gives us the following:

将此应用于点光源方向计算,我们得到以下结果:

Since the dot product of two vectors is equal to the product of the two vector’s lengths with the cosine of the angle between them, and the cosine of 0° is 1.0,the dot product of a vector with itself is the square of its length. So, to find the length of any vector,we just dot it with itself and take the square root of the result.

因为两个向量的点积等于两个向量的长度与它们之间角度的余弦的乘积,并且0°的余弦是1.0,所以向量与其自身的点积是其长度的平方。因此,要找到任何向量的长度,我们只需用它本身点积下,然后取结果的平方根。

The intermediate value that we need is r, the distance between the punctual light source and the currently shaded point. Besides its use in normalizing the light vector,the value of r is also needed to compute the attenuation (darkening) of the light color clight as a function of distance. This will be discussed further in the following section.

我们需要的中间值是r,点光源和当前阴影点之间的距离。除了用于归一化光矢量,r的值也需要计算光色光的衰减(变暗),作为距离的函数。这将在下一节中进一步讨论。

Point/Omni Lights 点/泛光灯

Punctual lights that emit light uniformly in all directions are known as point lights or omni lights. For point lights, clight varies as a function of the distance r, with the only source of variation being the distance attenuation mentioned above.

向各个方向均匀发光的点光源称为点光源或泛光灯。对于点光源,clight作为距离r的函数而变化,变化的唯一来源是上面提到的距离衰减。

Figure 5.5 shows why this darkening occurs, using similar geometric reasoning as the demonstration of the cosine factor in Figure 5.4.

图5.5显示了为什么会出现这种变暗现象,使用了与图5.4中余弦系数的论证相似的几何推理。

Figure 5.5. The spacing between light rays from a point light increases proportionally to the distance r. Since the spacing increase occurs in two dimensions, the density of rays (and thus the light intensity) decreases proportionally to .

图5.5。来自点光源的光线之间的间距与距离r成比例增加。由于间距的增加发生在二维空间中,因此光线密度(以及光强度)与成比例减少。

This enables us to specify the spatial variation in clight with a single light property, clight0 , which is defined as the value of clight at a fixed reference distance r0:

这使我们能够用单一光属性clight0指定clight的空间变化,clight 0定义为固定参考距离r0处的clight值:

Equation 5.11 is often referred to as inverse-square light attenuation. Although technically the correct distance attenuation for a point light, there are some issues that make this equation less than ideal for practical shading use.

等式5.11通常被称为平方反比光衰减。虽然从技术上来说,点光源的距离衰减是正确的,但是对于实际的着色使用来说,还有一些问题使得这个公式不太理想。

The first issue occurs at relatively small distances. As the value of r tends to 0,the value of clight will increase in an unbounded manner. When r reaches 0, we will have a divide-by-zero singularity. To address this, one common modification is to add a small value to the denominator

第一个问题发生在相对较小的距离。当r的值趋于0时,clight的值将以无界的方式增加。当r达到0时,我们将有一个被零除的奇点。为了解决这个问题,一个常见的修改是在分母上增加一个小的

The exact value used for depends on the application; for example, the Unreal game engine uses 

用于的确切值取决于应用;例如,虚幻游戏引擎使用 .

An alternative modification, used in the CryEngine and Frostbite game engines, is to clamp r to a minimum value rmin:

在CryEngine和Frostbite游戏引擎中使用的另一种修改将clamp r到最小值rmin:

Unlike the somewhat arbitrary value used in the previous method, the value of rmin has a physical interpretation: the radius of the physical object emitting the light.Values of r smaller than rmin correspond to the shaded surface penetrating inside the physical light source, which is impossible.

与前面方法中使用的有些随意的值不同,rmin的值有一个物理解释:发出光的物理对象的半径。小于rmin的r值对应于穿透物理光源内部的阴影表面,这是不可能的。

In contrast, the second issue with inverse-square attenuation occurs at relatively large distances. The problem is not with visuals but with performance. Although light intensity keeps decreasing with distance it never goes to 0.

相比之下,平方反比衰减的第二个问题发生在相对较大的距离。问题不在于视觉效果,而在于性能。尽管光强度随着距离的增加而不断降低,但它永远不会达到0。

For efficient rendering, it is desirable for lights to reach 0 intensity at some finite distance (Chapter 20). There are many different ways in which the inverse-square equation could be modified to achieve this. Ideally the modification should introduce as little change as possible. To avoid a sharp cutoff at the boundary of the light’s influence, it is also preferable for the derivative and value of the modified function to reach 0 at the same distance.

为了有效的渲染,希望灯光在有限的距离达到0强度(第20章)。有许多不同的方法可以修改平方反比方程来实现这一点。理想情况下,修改应该引入尽可能少的变化。为了避免在光影响的边界处突然截止,修改函数的导数和值在相同距离处达到0也是优选的。

One solution is to multiply the inverse-square equation by a windowing function with the desired properties. One such function is used by both the Unreal Engine and Frostbite game engines:

一种解决方案是将平方反比方程乘以具有所需属性的窗口函数。一个这样的函数被虚幻引擎和Frostbite游戏引擎使用:

The +2 means to clamp the value, if negative, to 0 before squaring it. Figure 5.6 shows an example inverse-square curve, the windowing function from Equation 5.14,and the result of multiplying the two.

+2表示在平方该值之前,如果该值为负值,则将其固定为0。图5.6显示了一个平方反比曲线的例子,方程5.14的窗口函数,以及两者相乘的结果。

Figure 5.6. This graph shows an inverse-square curve (using the method to avoid singularities, with an value of 1), the windowing function described in Equation 5.14 (with rmax set to 3), and the windowed curve.

图5.6。该图显示了一条平方反比曲线(使用方法避免奇点,值为1)、等式5.14中描述的窗口函数(rmax设置为3)和窗口曲线。

Application requirements will affect the choice of method used. For example,having the derivative equal to 0 at rmax is particularly important when the distance attenuation function is sampled at a relatively low spatial frequency (e.g., in light maps or per-vertex). CryEngine does not use light maps or vertex lighting, so it employs a simpler adjustment, switching to linear falloff in the range between 0.8rmax and rmax

应用要求将影响所用方法的选择。例如,当以相对低的空间频率(例如,在光照贴图或逐顶点中)对距离衰减函数进行采样时,在rmax处导数等于0是特别重要的。CryEngine不使用光照贴图或顶点照明,因此它采用了更简单的调整,切换到0.8rmax和rmax之间的线性衰减

For some applications, matching the inverse-square curve is not a priority, so some other function entirely is used. This effectively generalizes Equations 5.11–5.14 to the following:

对于某些应用来说,匹配平方反比曲线并不是优先考虑的事情,所以完全使用其他函数。这有效地将方程5.11-5.14推广到如下:

where fdist(r) is some function of distance. Such functions are called distance falloff functions. In some cases, the use of non-inverse-square falloff functions is driven by performance constraints.

其中fdist(r)是距离的函数。这种函数称为距离衰减函数。在某些情况下,非平方反比衰减函数的使用是由性能约束决定的。

For example, the game Just Cause 2 needed lights that were extremely inexpensive to compute. This dictated a falloff function that was simple to compute, while also being smooth enough to avoid per-vertex lighting artifacts

例如,游戏Just Cause 2只需要计算起来非常便宜的灯。这规定了一个衰减函数,它计算起来很简单,同时也足够平滑以避免每顶点的灯光伪像

In other cases, the choice of falloff function may be driven by creative considerations.For example, the Unreal Engine, used for both realistic and stylized games,has two modes for light falloff: an inverse-square mode, as described in Equation 5.12,and an exponential falloff mode that can be tweaked to create a variety of attenuation curves.

在其他情况下,衰减函数的选择可能是出于创造性的考虑。例如,用于真实和风格化游戏的虚幻引擎有两种灯光衰减模式:平方反比模式,如等式5.12中所述,以及指数衰减模式,可以调整该模式以创建各种衰减曲线。

The developers of the game Tomb Raider (2013) used spline-editing tools to author falloff curves, allowing for even greater control over the curve shape.

游戏《古墓丽影》(2013)的开发者使用样条编辑工具来创作衰减曲线,允许对曲线形状进行更大的控制。

Spotlights聚光灯

Unlike point lights, illumination from nearly all real-world light sources varies by direction as well as distance. This variation can be expressed as a directional falloff function fdir(l), which combines with the distance falloff function to define the overall spatial variation in light intensity:

与点光源不同,几乎所有真实光源的照明都随方向和距离而变化。这种变化可以表示为方向衰减函数fdir(l ),它与距离衰减函数结合来定义光强度的整体空间变化:

Different choices of fdir(l) can produce various lighting effects. One important type of effect is the spotlight, which projects light in a circular cone.

选择不同的fdir(l)可以产生不同的照明效果。一种重要的效果是聚光灯,它将光线投射成圆锥形。

A spotlight’s directional falloff function has rotational symmetry around a spotlight direction vector s, and thus can be expressed as a function of the angle θs between s and the reversed light vector −l to the surface. The light vector needs to be reversed because we define l at the surface as pointing toward the light, and here we need the vector pointing away from the light.

聚光灯的方向衰减函数具有围绕聚光灯方向向量s的旋转对称性,因此可以表示为s与表面反向光向量l之间的角度θs的函数。灯光向量需要反转,因为我们将曲面上的l定义为指向灯光,这里我们需要指向远离灯光的向量。

Most spotlight functions use expressions composed of the cosine of θs, which (as we have seen earlier) is the most common form for angles in shading. Spotlights typically have an umbra angle θu, which bounds the light such that fdir(l) = 0 for all θs ≥ θu.This angle can be used for culling in a similar manner to the maximum falloff distance rmax seen earlier. It is also common for spotlights to have a penumbra angle θp, which defines an inner cone where the light is at its full intensity. See Figure 5.7.

大多数聚光灯函数使用由θs的余弦组成的表达式,这是阴影中角度最常见的形式(正如我们前面看到的)。聚光灯通常有一个本影角度θu,它限制了光线,使得对于所有θs ≥ θu,fdir(l) = 0。该角度可用于剔除,其方式与前面看到的最大衰减距离rmax类似。聚光灯的半影角θp也很常见,半影角θp定义了光线处于最大强度的内锥。参见图5.7。

Figure 5.7. A spotlight: θs is the angle from the light’s defined direction s to the vector −l, the direction to the surface; θp shows the penumbra; and θu shows the umbra angles defined for the light.

图5.7。聚光灯:θs是从光的定义方向s到向量l的角度,向量l是表面的方向;θp表示半影;θu表示为光线定义的本影角度。

Various directional falloff functions are used for spotlights, but they tend to be roughly similar. For example, the function fdirF(l) is used in the Frostbite game engine, and the function fdirT(l) is used in the three.js browser graphics library:

各种方向衰减函数用于聚光灯,但它们大致相似。比如函数fdirF(l)用在Frostbite游戏引擎中,函数fdirT(l)用在three.js浏览器图形库中:

Recall that x+ is our notation for clamping x between 0 and 1, as introduced in Section 1.2. The smoothstep function is a cubic polynomial that is often used for smooth interpolation in shading. It is a built-in function in most shading languages.

回想一下,x+是我们将x clamping在0和1之间的符号,如1.2节所介绍的。smoothstep函数是一个三次多项式,通常用于着色中的平滑插值。它是大多数着色语言中的内置函数。

Figure 5.8 shows some of the light types we have discussed so far.

图5.8显示了我们到目前为止讨论过的一些光源类型。

Figure 5.8. Some types of lights. From left to right: directional, point light with no falloff, and spotlight with a smooth transition. Note that the point light dims toward the edges due to the changing angle between the light and the surface.

图5.8。一些类型的灯。从左到右:无衰减的平行光、点光源和平滑过渡的聚光灯。请注意,由于灯光和曲面之间的角度不断变化,点光源会向边缘变暗。

In Section 6.9 we will discuss how light intensity and color can be varied via the use of textures.

在6.9节中,我们将讨论如何通过使用纹理来改变光的强度和颜色。

Real-Time Rendering——5.2.2 Punctual Lights精准光相关推荐

  1. Real-Time Rendering 第五章 光照模型

    5.1 Shading Models shading model:决定了渲染管线的功能,也就是渲染的方式,根据不同的光照,视角,来渲染出不同的模型表面颜色 比如:Gooch shading model ...

  2. 前向渲染路径细节 Forward Rendering Path Details

    正向渲染路径细节 Forward Rendering Path Details Forward Rendering path renders each object in one or more pa ...

  3. 《Real-Time Rendering 4th Edition》读书笔记--简单粗糙翻译 第五章 着色基础 Shading Basics

    写在前面的话:因为英语不好,所以看得慢,所以还不如索性按自己的理解简单粗糙翻译一遍,就当是自己的读书笔记了.不对之处甚多,以后理解深刻了,英语好了再回来修改.相信花在本书上的时间和精力是值得的. -- ...

  4. Forward vs Deferred vs Forward+ Rendering with DirectX 11

    原文:http://www.3dgep.com/forward-plus/ Introduction Forward rendering works by rasterizing each geome ...

  5. keras 中adam_ADAM电影中的照明技巧和窍门

    keras 中adam Are you curious about how Oats Studios created such high-fidelity sets, characters and c ...

  6. unity 可视化渲染管线_如何为高端可视化设置Unity的高清渲染管道

    unity 可视化渲染管线 Prior to Unite Copenhagen in September 2019, Unity collaborated with Lexus and its age ...

  7. [图形学] 基于物理的渲染(PBR)

    reference :<real-time rendering 4> BRDF 概述 基于物理的渲染即计算沿着视线进入相机的光照辐射.如果不考虑吸收或散射的介质,则进入相机的辐射等于离开相 ...

  8. Crafting 手工 Physically Motivated Shading Models for Game Development

    http://renderwonk.com/publications/s2010-shading-course/hoffman/s2010_physically_based_shading_hoffm ...

  9. 【Unity Shader】(六) ------ 复杂的光照(上)

    笔者使用的是 Unity 2018.2.0f2 + VS2017,建议读者使用与 Unity 2018 相近的版本,避免一些因为版本不一致而出现的问题.              [Unity Sha ...

  10. Unity HDRP Volume框架 — Lighting(光照)

    Lighting(光照)参数设置 1.Screen Space Ambient Occasion(屏幕空间环境光遮蔽) 2.Volumetrics(体积光) 3.Light Layers(光照层) 4 ...

最新文章

  1. mysql期中考试题及答案_MySQL练习题及答案
  2. delete什么头文件C语言,C++中new和delete的介绍
  3. phpcms v9二次开发及使用中各种问题解决方案(一)
  4. Bootstrap基础二十七 多媒体对象(Media Object)
  5. 【Clickhouse】rsyslog服务器使用clickhouse列数据库存储日志
  6. c语言ut8,C语言使用utlist实现的双向链表
  7. matlab仿真软件 高阶调制,高阶差分幅度相移键控调制解调系统及仿真
  8. P3810 【模板】三维偏序(陌上花开)
  9. 扩展插件_Adobe扩展工具插件系列
  10. Parallels Desktop虚拟机无法关机提示“虚拟机处理器已被操作系统重置”
  11. ZEN CART 在LINUX系统下设置邮箱方法---用GMAIL设置,方法选择SMTPAUTH
  12. python中提取pdf文件某些页_人工智能|Python提取PDF中的文本并朗读
  13. MongoDB(Golang)常用复合查询
  14. 从盒子到“云”——让用户享受更轻松的应用交付
  15. 华为路由器配置备忘录
  16. 备战2018|春招or跳槽?大学生和职场新人最后的机会!
  17. 软件开发项目计划编制过程[转]
  18. 移动APP和小程序的低代码开发平台有哪些
  19. 人民网:“2021数字基建论坛”在京召开,共议行业高质量发展
  20. CentOS 7 安装极点五笔输入法

热门文章

  1. 如何用Python获取网页指定内容
  2. phyton做年历和月历
  3. Codeforces Round #614 (Div. 2)A. ConneR and the A.R.C. Markland-N
  4. 微信小程序无法获取头像,昵称的解决办法 (原生)
  5. 云杰恒指:6.11恒指期货实盘指导交易复盘
  6. 【演示文稿制作软件】Focusky教程 | 贯穿整个演示文稿背景音乐的添加与设置
  7. 教你微信怎么投票快之微信投票快速投票方法
  8. 记一次Python爬取某网站公众号二维码的过程
  9. 使用 Cloudflare 进行域名跳转(重定向)
  10. python中dispatch_在django,dispatch的用途是什么?