光线的工作原理和阴影类型-卡洛斯·莱莫斯-双语
2806 0
实名

通过了实名认证的内容创造者

发布于 2022-8-5 14:32:36

您需要 登录 才可以下载或查看,没有账号?注册

x
本帖最后由 七月纪旅。 于 2022-8-6 11:05 编辑

1.jpeg

What is Light?
什么是光?
If we want to learn how to replicate light, we should know how light works in the real world.
The thing is, it’s too complicated. If we tried to replicate it exactly, it would take way too much time, so the general approach is to look for a way to get a good enough result by analyzing the different effects that form lighting, decomposing them into parts and combining them to get a good enough result.
如果我们想学习如何复制光,我们应该知道光在现实世界中是如何工作的。
问题是,这太复杂了。如果我们试图精确地复制它,这将花费太多时间,所以一般的方法是寻找一种方法来获得足够好的结果,通过分析形成照明的不同效果,将它们分解成部分并将它们组合在一起以获得足够好的结果。
In this article, I will try to summarize these effects and study a bit of them, so that we understand how they work and improve how we render things. I will also try to keep it simple and talk about we approach lighting in non-realtime CGI, real-time CGI, and illustration so everybody can get something from it.
在本文中,我将尝试总结这些效果并研究其中的一些效果,以便我们了解它们的工作原理并改进我们渲染事物的方式。我还将尽量保持简单,并讨论我们在非实时CGI,实时CGI和插图中接近照明,以便每个人都可以从中获得一些东西。
Let’s consider light as a series of rays (it isn’t, but it's close enough for what we need). Light sources emit rays that scatter through the world. When those rays reach our eyes, we see the light reflecting off those objects. Based on this behaviour, we can define emission (light gets emitted from a light source), reflection (light bounces from objects), transmission (light goes through an object), and absorption (light gets absorbed by an object, heating up).
让我们把光看作是一系列光线(它不是,但它足够接近我们所需要的)。光源发出的光线散射到整个世界中。当这些光线到达我们的眼睛时,我们看到光线从这些物体反射出来。基于这种行为,我们可以定义发射(光从光源发射),反射(光从物体反弹),透射(光通过物体)和吸收(光被物体吸收,升温)。
Emission
排放
Light gets emitted from a light source when that source is at a high energy state and emits light in order to get into a lower energy state.
当光源处于高能态时,光从光源发射并发光以进入较低能量状态。
In most cases, emission comes from incandescence: we charge a substance with electrical energy, and it releases the energy as light, but there are other sources (blackbody radiation, fluorescence, phosphorescence, particle acceleration, radioactive decay, lasers, fire, etc.)
在大多数情况下,发射来自白炽灯:我们用电能为物质充电,它以光的形式释放能量,但还有其他来源(黑体辐射,荧光,磷光,粒子加速,放射性衰变,激光,火灾等)。
Visually, light sources are very similar and they usually only change in intensity and color, not how they interact with matter.
从视觉上看,光源非常相似,它们通常只在强度和颜色上发生变化,而不是它们与物质相互作用的方式。
In this scene, we have: a floor, a sphere that is emitting light towards the floor, and a white light.
在这个场景中,我们有:一个地板,一个向地板发光的球体,以及一个白光:

2.jpeg

Reflection
反射
Light can bounce from the object, giving us reflected light. We separate reflected light into 2 different types of reflections:
光可以从物体反射,给我们反射光。我们将反射光分为两种不同类型的反射:
Diffuse Reflection: the ray of light can penetrate slightly the surface of the object, interacting with its molecules and bouncing back in a random direction. Since the light interacts with the object intensely, some part of it gets absorbed, and the reflected light is colored. Most of the reflections in a material work like this.
漫反射:光线可以稍微穿透物体的表面,与其分子相互作用,并在随机方向上反弹。由于光与物体强烈相互作用,因此它的某些部分被吸收,反射光被着色。材料中的大多数反射都是这样工作的。


Specular reflection: light can bounce back at a perfect angle and go towards the viewer creating a specular reflection. Since the light interacts very briefly with the object, specular reflections usually keep the color of the light source ignoring the color of the object.
镜面反射:光线可以以完美的角度反射回来,并朝向观看者,从而产生镜面反射。由于光与物体的相互作用非常短暂,因此镜面反射通常会使光源的颜色忽略物体的颜色。


Transmission
传输

If the ray of light can go through the object, we will get some effects such as:
如果光线可以穿过物体,我们将得到一些效果,例如:
Transparency: the ray of light goes through the object and its direction is unchanged. This is what happens in real life with most gasses.
透明度:光线穿过物体,其方向不变。这就是现实生活中大多数气体所发生的事情。


Translucency: because light can travel at different speeds depending on the medium it’s passing through, when it passes through many different mediums with different properties, it appears to bend. This is what happens in real life with water, glass, etc.
半透明性:由于光可以以不同的速度传播,具体取决于它所经过的介质,当它穿过许多具有不同性质的不同介质时,它似乎会弯曲。这就是现实生活中发生的水,玻璃等。


The relative speed at which light travels through a material is called the index of refraction of that material. Refraction can also cause other effects, such as rainbows, caustics, or prisms.
光穿过材料的相对速度称为该材料的折射率。折射还可能导致其他影响,例如彩虹、焦散或棱镜。

Subsurface Scattering: a translucent object might receive light, which interacts with the object intensely (getting colored) and bounces back out of the object making the object look emissive, especially on thin surfaces where it is more likely for light to go through the object.
地下散射:半透明物体可能接收光,光与物体强烈相互作用(着色)并从物体中反弹回来,使物体看起来发光,特别是在薄表面上,光线更有可能穿过物体。


Absorption
吸收
Light is energy, and when it hits an object, its energy can be absorbed by the object, which heats up as a result. In fact, objects can absorb not only visible but also other kinds of invisible light (ultraviolet, infrared, etc.). Absorbed light is invisible and doesn't affect our images.
光是能量,当它击中物体时,它的能量可以被物体吸收,从而升温。事实上,物体不仅可以吸收可见光,还可以吸收其他类型的不可见光(紫外线,红外线等)。吸收的光是不可见的,不会影响我们的图像。

Direct and Indirect Lighting
直接和间接照明

When we consider only the first bounce of light, we are only considering direct lighting: light that bounces from an object and straight into the camera. However, light bounces around everywhere (and it bounces even more if we consider that it’s not exactly a particle) and many times.
当我们只考虑光的第一次反射时,我们只考虑直接照明:从物体反射并直接进入相机的光。然而,光在任何地方都会反弹(如果我们认为它不完全是一个粒子,它会反弹得更多)和很多次。
This is why we also have to include extra light in our scenes that fills the very dark parts of the shadows representing these extra rays of light bouncing everywhere. This extra light is called indirect light, ambient light, or global illumination.
这就是为什么我们还必须在场景中包含额外的光线,这些光线填充了阴影中非常黑暗的部分,代表这些额外的光线到处反弹。这种额外的光称为间接光、环境光或全局照明。


Indirect light is very weak: if a single bounce usually results in 18% of the original light bounced, 2 bounces would result in 3.24% of the original light intensity. Nevertheless, it is very noticeable because a bit of light on a completely dark surface is very noticeable.
间接光非常弱:如果单个反射通常会导致18%的原始光反弹,则2次反射将导致原始光强度的3.24%。然而,它非常明显,因为在完全黑暗的表面上有一点光是非常明显的。
Indirect lighting is quite hard to get right because we have to consider the entire scene, how light bounces between objects, how color is being added to each object, etc. Some of the most common approaches include:
间接照明很难正确,因为我们必须考虑整个场景,光线如何在对象之间反弹,如何为每个对象添加颜色等。一些最常见的方法包括:
Calculate it accurately tracking how light should bounce around the scene and combine it with the direct lighting. This process is obviously the most accurate, but it is very slow in CGI and very hard to get right in illustration:
计算它,准确地跟踪光线在场景中应该如何反弹,并将其与直接照明相结合。这个过程显然是最准确的,但在CGI中非常慢,在插图中很难正确:


Add a fill/ambient color: instead of leaving the shadowed parts of our scene completely dark, we use a base color that fills them (usually the sky color or the color of the largest light source) to represent how the environment light is filling these dark areas with its bouncing indirect light.
添加填充/环境色:我们不是让场景中的阴影部分完全变暗,而是使用填充它们的基色(通常是天空颜色或最大光源的颜色)来表示环境光如何用其反射的间接光填充这些黑暗区域。


Use the base color of each object: it's frequently used in illustration. Instead of starting with a black canvas and adding the light from each source, we usually start with base colors and add shading on top of them. This way, shade areas will keep some of the color that indirect lighting would light, allowing us to see the base color of the surfaces.
使用每个对象的基色:它经常用于插图。我们通常不是从黑色画布开始并添加来自每个光源的光线,而是从基色开始,并在其顶部添加阴影。这样,阴影区域将保留间接照明将照亮的一些颜色,从而使我们能够看到表面的基色。


If we start from a base color and darken it for shadow areas while keeping the base color perceivable, we are recreating indirect light reaching those shadow areas.
如果我们从基色开始,在保持基色可感知的同时将其变暗以阴影区域,则我们正在重新创建到达这些阴影区域的间接光。
Warning: some people also refer to the base color of the object as the albedo color or diffuse color. Technically, diffuse color should include shading (light+shadow) and albedo color should be the flat color (without lights or shadows), but these terms are commonly used without distinction.
警告:有些人还将物体的基色称为反照率颜色或漫反射色。从技术上讲,漫反射颜色应包括阴影(光+阴影),反照率颜色应为平面颜色(无光或阴影),但这些术语通常不加区分地使用。

Add a fill light: in CG, we can add a fill light (sometimes it's the same as an ambient color), which is a light that illuminates all objects from all angles.
添加补光:在CG中,我们可以添加补光(有时它与环境色相同),这是一种从各个角度照亮所有对象的光。


A similar approach would be to capture the environment as a 360o image and use it as a fill light to fill the shadows with the color of the environment. For instance, we can use a Skylight in Unreal Engine to capture the scene and use it to fill dark areas simulating indirect lighting in real-time.
类似的方法是将环境捕获为360o图像,并将其用作补光灯,以用环境的颜色填充阴影。例如,(我们可以在虚幻引擎中使用天窗来捕捉场景),并用它来填充暗区,实时模拟间接光照。
The Story So Far
到目前为止的故事
So, how can we form an image using what we have discussed so far? Let’s take a look:
那么,我们如何利用到目前为止所讨论的内容来形成图像呢?让我们来看看:
Starting from complete darkness, we add light sources to our environment and calculate the direct lighting: light comes out of the light sources, bounces once on the environment, and goes into the camera. As we have seen, there are diffuse and specular bounces:
从完全黑暗开始,我们将光源添加到环境中并计算直接照明:光线从光源中出来,在环境中反弹一次,然后进入相机。正如我们所看到的,存在漫反射和镜面反射:




This is nice, but light in real life bounces more than once – we need to incorporate these extra bounces (indirect light) into our scene:
这很好,但现实生活中的光线会反弹不止一次 - 我们需要将这些额外的反弹(间接光线)合并到我们的场景中:


And aside from bounces, light can also go through objects (transmission):
除了反弹之外,光线还可以穿过物体(透射):


When we combine everything together, we have our render:
当我们将所有内容组合在一起时,我们就有了渲染:


So, what we need to represent light is the sum of direct lighting (diffuse and specular), transmission, and indirect lighting. We could also add some extra effects, such as caustics, bloom, motion blur, etc., but those are the basic pieces that we should keep in mind.
因此,我们需要表示光的是直接照明(漫射和镜面光),透射和间接照明的总和。我们还可以添加一些额外的效果,例如焦散,绽放,运动模糊等,但这些是我们应该牢记的基本部分。
Depending on our media, we approach this in different ways:
根据我们的媒体,我们以不同的方式处理这个问题:
In non-realtime CGI, we throw rays from the light sources into the scene (ray tracing), track how they bounce, and add them together to generate the image.
在非实时CGI中,我们将光源的光线投射到场景中(光线追踪),跟踪它们如何反弹,并将它们加在一起以生成图像。
In real-time CGI, we generate temporary images of the scene with the information we need (color, roughness, depth, etc.) and use optimized math formulas that calculate the color of each pixel using the scene settings and these temporary images.
在实时CGI中,我们使用所需的信息(颜色,粗糙度,深度等)生成场景的临时图像,并使用优化的数学公式,使用场景设置和这些临时图像计算每个像素的颜色。
In illustration, we usually start with the diffuse color because it is usually the most important component, add shadows (so we get the direct diffuse reflections and a base for indirect lighting), add specular reflections on top of all, and finally tweak everything until we get the desired result.
在插图中,我们通常从漫反射颜色开始,因为它通常是最重要的组成部分,添加阴影(因此我们获得直接漫反射和间接照明的基础),在所有颜色上添加镜面反射,最后调整所有内容,直到我们得到所需的结果。
Light Has to Get Somewhere
光必须到达某个地方
When light hits an object, the incident light is either reflected, transmitted (goes through the object), or absorbed; and it is conserved during this process: incident light is equal to the sum of reflected, transmitted, and absorbed light. In real life, there are other processes that can affect light, but they are negligible for rendering.
当光线照射到物体上时,入射光要么被反射,要么透射(穿过物体),要么被吸收;并且在此过程中它是守恒的:入射光等于反射光,透射光和吸收光的总和。在现实生活中,还有其他过程会影响光线,但对于渲染来说,它们可以忽略不计。
Because absorption is invisible, we can reduce the amount of light that is bounced from the object and assume that the rest is absorbed. However, we can’t increase it because we would be generating light from nothing. This is relevant as old lighting models in CGI did not respect this law, and we could have objects reflecting more light than they should.
因为吸收是不可见的,我们可以减少从物体反射的光量,并假设其余的被吸收。然而,我们不能增加它,因为我们会从无到有地产生光。这是相关的,因为CGI中的旧照明模型不尊重这个定律,我们可以让物体反射比它们应该反射的更多的光。
Reflections in Detail
详细反思
When light interacts with an opaque object, some part of it gets absorbed by the object (which gets hot as a result), and the rest of it bounces. When that bounced light reaches a camera or our eyes, we can see the object.
当光线与不透明物体相互作用时,它的某些部分被物体吸收(结果变热),其余部分反弹。当反射的光到达相机或我们的眼睛时,我们可以看到物体。
The percentage of light that gets reflected by a material is called the Albedo, and it ranges widely between different materials.
被材料反射的光的百分比称为反照率,它在不同材料之间分布广泛。
If we had a material with an albedo of 100, it would reflect all light. It would not only be a perfect mirror but it would also be very cold as sunlight just wouldn’t heat it directly. Usually, the highest albedo is found on new clear snow at about 80. The main implication of this is that we should avoid using pure white as a color because a surface with 100% pure white would actually have to be actively emitting light, not just reflecting it. Of course, there are other factors to consider (white balance, exposure, eye adaptation) but as a general rule of thumb, it's a good idea to avoid using pure white and pure black.
如果我们有一种反照率为100的材料,它将反射所有光线。它不仅是一面完美的镜子,而且会非常冷,因为阳光不会直接加热它。通常,最高的反照率是在大约80的新清雪上发现的。这样做的主要含义是,我们应该避免使用纯白色作为颜色,因为具有100%纯白色的表面实际上必须主动发光,而不仅仅是反射它。当然,还有其他因素需要考虑(白平衡,曝光,眼睛适应),但作为一般经验法则,避免使用纯白色和纯黑色是一个好主意。
There are two main types of light reflection: specular and diffuse reflection. The sum of these reflections gives us the albedo.
光反射主要有两种类型:镜面反射和漫反射。这些反射的总和给了我们反照率。
Non-metallic materials (dielectric) reflect between 2 and 5% (4% being the average) of light in a specular way and a wider range of light: 0.5-75% in a diffuse way (14% on average). The sum of reflected light (specular + diffuse) is the albedo value (18% on average). The rest gets absorbed by the material as heat.
非金属材料(电介质)以镜面反射2%至5%(平均4%)的光和更宽范围的光:以漫射方式反射0.5-75%(平均14%)。反射光(镜面反射+ 漫反射光)的总和是反照率值(平均为 18%)。其余的被材料吸收为热量。


Metals are weird, they reflect 50-99% of light in a specular way and don’t have diffuse reflections.
金属很奇怪,它们以镜面反射50-99%的光,并且没有漫反射。


Diffuse Bounces in Detail
漫反射细节
As we have seen, in a diffuse bounce, the ray of light can penetrate slightly the surface of the object interacting with it and releasing back out in a random direction.
正如我们所看到的,在漫反射中,光线可以稍微穿透与之相互作用的物体表面,并以随机方向释放出来。
Diffuse bounces carry the color of the object.
漫反射携带对象的颜色。


In a diffuse bounce, light penetrates the outermost layers of the object, the object absorbs part of the light (heating as a result) and releases the light in all directions, which is now colored as it got partially absorbed by the object.
在漫反射中,光穿透物体的最外层,物体吸收部分光(结果加热)并向所有方向释放光,现在当它被物体部分吸收时,光是彩色的。
Diffuse bounces throw light in all directions, everywhere.
漫反射向各个方向、各个方向投射光线。
This means that a specific point of the object will have the same light intensity no matter where we look at it from.
这意味着无论我们从哪里看,物体的特定点都将具有相同的光强度。
The point of the object that is closest to the light will have the most brightness, and the less exposed points will be dark. This is a very important distinction from the specular bounces, where the viewing angle does matter.
最接近光线的对象点将具有最大的亮度,而曝光较少的点将变暗。这与镜面反射是一个非常重要的区别,在镜面反射中,视角确实很重要。


The surface roughness is irrelevant for diffuse bounces.
表面粗糙度与漫反射无关。
Since light gets scattered everywhere with diffuse bounces, the surface roughness is irrelevant for diffuse bounces: we can polish a red surface and make its surface smoother, but it will always be red.
由于光线通过漫反射散射到各处,因此表面粗糙度与漫反射无关:我们可以抛光红色表面并使其表面更光滑,但它将始终是红色的。
Specular Bounces in Detail
镜面反射细节
In my opinion, specular bounces are easier to understand because it’s what comes to our heads when we think of a bounce.
在我看来,镜面反射更容易理解,因为当我们想到反弹时,它就会浮现在我们的脑海中。
The light bounces back from the object at a symmetrical angle and goes towards the viewer creating a specular reflection, like a ball thrown towards a wall.
光线以对称的角度从物体反射回来,并朝向观看者,产生镜面反射,就像一个球扔向墙壁一样。


Specular reflections keep the color of light.
镜面反射可保持光线的颜色。
Since the light interacts very briefly with the object, specular reflections keep the color of the light source, ignoring the color of the object. This is the white highlight that we see on a smooth plastic surface: it doesn’t matter what the color of the plastic is, this reflection is always the color of the light (usually white) because that’s the color of the light source, and the specular highlight doesn’t modify it.
由于光与物体的相互作用非常短暂,因此镜面反射保留了光源的颜色,忽略了物体的颜色。这是我们在光滑的塑料表面上看到的白色高光:塑料的颜色是什么并不重要,这种反射总是光的颜色(通常是白色),因为这是光源的颜色,而镜面高光不会改变它。

These objects have different colors (set by the diffuse bounces), but their specular highlight is the color of the light (white).
这些对象具有不同的颜色(由漫反射设置),但它们的镜面反射高光是光的颜色(白色):


Specular highlights
镜面高光
In a specular reflection, the entire environment is being reflected, but light sources are much brighter than the environment, so a lot of times these light sources are the only specular reflection that we notice. These reflected light sources are usually named specular highlights.
在镜面反射中,整个环境都被反射,但光源比环境亮得多,所以很多时候这些光源是我们注意到的唯一镜面反射。这些反射光源通常称为镜面高光。

This traffic light projects a colored specular reflection on the ground. The entire environment is being reflected, but we mostly see the light because it is a much stronger light source than the rest of the environment.
这个交通灯在地面上投射出彩色的镜面反射。整个环境都在被反射,但我们看到的大多是光,因为它是比环境其他部分强得多的光源:


Specular reflections are view-dependent.
镜面反射与视图相关。
This kind of reflection is dependent on the viewer's angle: we only see the light that is perpendicular to the surface we are looking at. If we change the viewing angle, the highlight will “move (relative to the object)”. The intensity of the reflection will be greater as the viewing angle gets more parallel to the surface.
这种反射取决于观看者的角度:我们只看到垂直于我们正在观察的表面的光。如果我们改变视角,高光将“移动(相对于对象)”。随着视角越来越平行于表面,反射的强度将更大。




The specular reflection on this bird figurine seems to be placed on the eye in the first picture, while in the second image seems to be placed on the spine.
在第一张图片中,这只鸟雕像上的镜面反射似乎被放置在眼睛上,而在第二张图片中,它似乎被放置在脊柱上:


Specular reflections look different depending on surface roughness.
镜面反射看起来因表面粗糙度而异。
If the surface is perfectly smooth, the reflected light will be very similar to the source (like a mirror), and if it's rough, the bounced image will be blurry. Instead of having to model microscopic details to represent these surfaces, computer shaders usually have a way of simulating those details, usually a roughness or smoothness value that we can adjust using a value or a texture.
如果表面非常光滑,反射光将与光源非常相似(如镜子),如果粗糙,则反射的图像将模糊。计算机着色器通常不必对微观细节进行建模来表示这些表面,而是有一种方法可以模拟这些细节,通常是粗糙度或平滑度值,我们可以使用值或纹理进行调整。


Notice how all the spheres are always red: the color of the object depends on diffuse reflections, which are independent of surface roughness (no matter how much we polish a red ball, it is still red). Only specular reflections are affected by surface roughness.
请注意,所有球体始终是红色的:物体的颜色取决于漫反射,这与表面粗糙度无关(无论我们打磨红色球多少,它仍然是红色的)。只有镜面反射会受到表面粗糙度的影响。
The specular highlight of a smooth surface looks brighter than the specular highlight of a rough surface because the rough surface scatters light everywhere, while the smooth surface directs it towards the viewer. The amount of reflected light is the same, the rough surface simply scatters it, making the highlight larger and dimmer.
光滑表面的镜面高光看起来比粗糙表面的镜面高光更亮,因为粗糙表面将光线散射到各处,而光滑表面将其引导到观看者。反射光的量是相同的,粗糙的表面只是散射它,使高光更大,更暗。
Fresnel effect
菲涅耳效应
Now, let’s imagine that we have a rock and a pool full of water. Let’s throw the rock directly into the water, simply letting it fall down from a great height. Will it bounce?
现在,让我们想象一下,我们有一块石头和一个充满水的水池。让我们把石头直接扔进水里,让它从高处掉下来。它会反弹吗?
Of course not. It simply goes through the water and falls to the sea floor. But what if we throw it at an angle? At a 45o angle, the rock will probably still fall down, but at very low angles, the rock bounces (skipping stones). At some angles, where the movement direction of the rock is almost horizontal; it's more likely for the rock to bounce than it is to go through the surface.
当然不是。它只是穿过水面,落到海底。但是,如果我们把它扔到一个角度呢?在45o角下,岩石可能仍然会掉下来,但在非常低的角度下,岩石会反弹(跳过石头)。在某些角度,岩石的运动方向几乎是水平的;岩石反弹的可能性比穿过表面的可能性更大。
The same thing happens with light when it comes to specular bounces.
当涉及到镜面反射时,光也会发生同样的事情。
If we throw a ray of light perpendicular to a surface, it is more likely to be absorbed by the surface than it is to bounce. However, if we throw it almost parallel to the surface, it will be more likely to bounce and generate a specular bounce.
如果我们抛出垂直于表面的光线,它更有可能被表面吸收而不是反弹。但是,如果我们将其几乎平行于表面投掷,它将更有可能反弹并产生镜面反射。



This effect is called the Fresnel effect, and it basically means that surfaces are more specular when looked at at extreme angles. Because of this, specularity is calculated at a perpendicular viewing angle, called f0; instead of any angle.
这种效应被称为菲涅耳效应,它基本上意味着在极端角度下观察时,表面更加镜面反射。因此,在垂直视角下计算镜面反射率,称为f0;而不是任何角度。
One of the clearest examples of this is water: when we look at a water surface straight down, it is transparent and we can see what's inside the water; and when we look at it horizontally (looking at the sea at the horizon), the specular bounces are much more likely, and the water reflects light like a mirror.
最明显的例子之一是水:当我们直视水面时,它是透明的,我们可以看到水里面有什么;当我们水平观察它(看着地平线上的大海)时,镜面反射的可能性要大得多,水像镜子一样反射光线。


In this image, we can see through the water when looking at the nearby rocks, but the far away zones look more reflective because water has a fresnel effect: it is much more specular when looked at from a parallel angle and less specular when seen from a perpendicular angle.
在这张照片中,当观察附近的岩石时,我们可以透过水看到,但是远处的区域看起来更具反射性,因为水具有菲涅耳效应:从平行角度观察时,它更具镜面反射性,而从垂直角度观察时,镜面反射率更低。
Metals
五金
Metallic objects are weird. Metals are very, very dense. So dense that it’s pretty much impossible for a metal in the real world to become transparent (gold leaves can be a hundred atoms wide and still be opaque).
金属物体很奇怪。金属非常非常致密。如此致密,以至于现实世界中的金属几乎不可能变得透明(金叶可以有一百个原子宽,但仍然不透明)。
When light hits a metal surface, most of it bounces off: while most materials have a lot of diffuse reflections and a few specular reflections, metals have a lot of specular reflections and no diffuse reflections. Light simply cannot get inside the metal surface to interact with the metal atoms, get partially absorbed and get out in a diffuse bounce. Instead, it just bounces off. In a metallic object, around 50-99.8% of the light gets reflected specularly, and the rest gets absorbed.
当光线照射到金属表面时,大部分会反弹:虽然大多数材料具有大量的漫反射和一些镜面反射,但金属具有大量的镜面反射并且没有漫反射。光根本无法进入金属表面与金属原子相互作用,被部分吸收并以漫反射的形式射出。相反,它只是反弹。在金属物体中,大约50-99.8%的光被镜面反射,其余的被吸收。


What color is a mirror? It's hard to tell because mirrors are made of metals and they reflect most of the light in a specular way.
镜子是什么颜色的?这很难说,因为镜子是由金属制成的,它们以镜面反射大部分光线。
Some metals can also add a little bit of color to the reflected light making it look like they have a color (gold, copper, etc.), but in reality they are just modifying the color of reflected light: specular highlights keep the color of the light in non-metallic surfaces, but can be altered in metallic surfaces.
一些金属还可以为反射光添加一点颜色,使其看起来像有颜色(金色,铜等),但实际上它们只是在修改反射光的颜色:镜面高光将光的颜色保留在非金属表面,但可以在金属表面改变。
In the case of metallic surfaces, since most of its surface is reflecting the environment, their look can vary immensely depending on the environment and the viewing angle. As a result, they are hard to draw, and if we wanted to render them correctly in 3D, we would have to “render again” the entire scene. A common solution is to make these metal parts very rough in order to make the reflection quite blurry and avoid distinguishable details that might not fit with every environment.
在金属表面的情况下,由于其大部分表面都反映了环境,因此它们的外观可能会因环境和视角而有很大差异。因此,它们很难绘制,如果我们想在3D中正确渲染它们,我们将不得不“再次渲染”整个场景。一种常见的解决方案是使这些金属零件非常粗糙,以使反射非常模糊,并避免可能不适合每种环境的可区分细节。


Transmission
传输
When a light ray reaches an object, it can go through it. This process has many names. I've decided to use the term transmission, which is the one used in ray tracing CGI.
当光线到达物体时,它可以穿过它。此过程有许多名称。我决定使用术语传输,这是光线追踪CGI中使用的术语。
Keep in mind that light has to be conserved: if a transparent object has reflections or if it's colored, light has to be dimmer when it goes through it. For instance, when a surface gets wet, it might have a stronger specular reflection because of the water on top of it. The light that is getting reflected specularly doesn’t reach the object and doesn’t contribute to the diffuse reflections making the object look darker.
请记住,光线必须守恒:如果透明物体有反射或有色,则光线在穿过它时必须变暗。例如,当表面变湿时,由于表面上的水,它可能具有更强的镜面反射。镜面反射的光不会到达物体,也不会导致漫反射使物体看起来更暗。
Transmission can take many forms.
传播可以采取多种形式。
Translucency
半透明
When light passes through many different mediums with different properties, it appears to bend. This is what happens in real life with water, glass, etc.
当光线穿过许多具有不同性质的不同介质时,它似乎会弯曲。这就是现实生活中发生的水,玻璃等。
Light can travel at different speeds depending on the medium it’s passing through. You might remember that the speed of light is about 299 792 458 m/s, but that is measured in a vacuum. While it is going through a medium it might go slower (not 100% true, but let's skip the relativity theory) depending on the refraction index of that medium.
光可以以不同的速度传播,这取决于它所经过的介质。你可能还记得光速大约是299 792 458 m/s,但这是在真空中测量的。当它通过介质时,它可能会变慢(不是100%正确,但让我们跳过相对论),这取决于该介质的折射率。


In some mediums, the light goes faster or slower than in the air, and that can cause incident light rays to bend when going through the medium in a phenomenon called refraction.
在某些介质中,光比空气中更快或更慢,这可能导致入射光线在穿过介质时弯曲,这种现象称为折射。


Heavily compressed air is denser than regular air, and the light goes through it slower. This is why explosions can create visual shockwaves: air is much denser here and we get refraction effects between regular air and heavily compressed air.
重压缩空气比普通空气密度更大,光线通过它的速度更慢。这就是为什么爆炸会产生视觉冲击波:这里的空气密度要大得多,我们在普通空气和重压缩空气之间会产生折射效应。
A completely translucent object is invisible, however, it can still be perceived because it bends light, changing how objects behind it are seen.
一个完全半透明的物体是不可见的,但是,它仍然可以被感知,因为它弯曲了光线,改变了它后面的物体被看到的方式。
Refraction can also cause other related effects, such as rainbows, prisms, iridescence, etc.
折射还会引起其他相关影响,如彩虹、棱镜、虹彩等。
Transparency
透明度
The ray of light goes through the object and its direction is unchanged. This is what happens in real life with most gasses. Visually, a completely transparent object is invisible. However, a partially transparent object can be seen.
光线穿过物体,其方向不变。这就是现实生活中大多数气体所发生的事情。在视觉上,完全透明的对象是不可见的。但是,可以看到部分透明的对象。


A partially transparent object will tint the objects behind it with its diffuse color. This type of transmission is mostly used as a cheap way of translucency in CGI: in real life, almost all objects have a refraction index distinct from 1 (air) and will bend light in some way.
部分透明的对象将以其漫反射颜色为其后面的对象着色。这种类型的透射主要用作CGI中一种廉价的半透明性方式:在现实生活中,几乎所有物体的折射率都与1(空气)不同,并且会以某种方式弯曲光线。
Subsurface Scattering
地下散射
Subsurface scattering is a mix between diffuse reflection and translucency: light can penetrate an object, start reflecting inside the object with diffuse bounces, and get out the other side of the object, especially on thin surfaces where it is more likely for light to go through the object.
地下散射是漫反射和半透明性的混合:光可以穿透物体,开始以漫反射反射物体里面,并从物体的另一侧出来,特别是在薄表面上,光线更有可能穿过物体。


Subsurface scattering is colored, with a color that is a mix between the diffuse color of the object (because of the light rays diffusely scattered) and the color of the light (because of the light rays transmitted through the object). It can make surfaces look emissive when looked at from the shadowed side, and it is sometimes faked with emissive materials.
次表面散射是彩色的,其颜色是对象的漫反射颜色(由于光线漫射散射)和光的颜色(由于通过对象传输的光线)之间的混合。当从阴影侧观察时,它可以使表面看起来发光,并且有时用发光材料伪造。
Combining Light Sources
组合光源
What if we have different light sources? How do they add up?
如果我们有不同的光源呢?它们是如何相加的?
If we take a photograph with 4 different light sources turned on and 4 photographs (or renders) with each individual light turned on and the rest off, can we simply add the individual photographs to generate the same result?
如果我们在打开4个不同光源和4张照片(或渲染)的情况下拍摄照片,每个单独的灯都打开,其余的都关闭,我们是否可以简单地添加单独的照片来产生相同的结果?
4 light sources turned on
4 个光源已打开:


Each light source turned on individually
每个光源单独打开


Yes.
是的。


If we compare the generated image with the one with all lights turned on, we can see that they are basically the same. This means that we can work on each light source separately and add them; light sources can be added linearly.
如果我们将生成的图像与所有灯都打开的图像进行比较,我们可以看到它们基本上是相同的。这意味着我们可以分别处理每个光源并添加它们;光源可以线性添加。
Well, kind of. While the light from different light sources can be added, keep in mind that our eyes adjust to the amount of light that we are seeing, and past a certain threshold, our eyes readapt in a similar way to how we stop perceiving a strong smell after a while so that we can focus on other smells (also, gamma correction and other effects could interfere).
嗯,差不多吧。虽然可以添加来自不同光源的光,但请记住,我们的眼睛会根据我们看到的光量进行调整,并且超过一定阈值,我们的眼睛会以类似于我们在一段时间后停止感知强烈气味的方式重新吸收,以便我们可以专注于其他气味(此外, 伽马校正和其他效应可能会干扰)。
This is yet another reason why you should avoid 100% white: our eyes would adapt to avoid losing the information that we can’t see because our light receptors are flooded.
这是你应该避免100%白人的另一个原因:我们的眼睛会适应,以避免丢失我们看不到的信息,因为我们的光受体被淹没了。
Shadows
阴影
In CGI, we usually start with black color for the entire scene and start adding lights. However, when drawing we usually start with the diffuse color and add both lights and shadows.
在CGI中,我们通常从整个场景的黑色开始,然后开始添加灯光。但是,在绘制时,我们通常从漫反射颜色开始,并添加光和阴影。


A shadow is the absence of light. Depending on their appearance, shadows can be split into three groups:
阴影是光的缺失。根据其外观,阴影可以分为三组:
Form shadows – shadows created on the surface of objects simply because they are less exposed to the light. Form shadows come from the lack of diffuse reflections: the parts of the object that are exposed to the light will reflect it, but the parts that are less exposed (facing away from the light) will not, and they will look darker. These shadows are usually smooth and subtle and give us a lot of information about the volume of the object.
形成阴影 – 在物体表面创建的阴影,仅仅是因为它们对光线的暴露程度较低。形成阴影来自缺乏漫反射:暴露在光线下的物体部分将反射它,但曝光较少的部分(面向远离光线)则不会,并且它们看起来会更暗。这些阴影通常是平滑和微妙的,并为我们提供了有关物体体积的大量信息。


Cast shadows – shadows created when an object or a part of an object gets between a source of light and another object. Unlike form shadows, which affect only the same object, cast shadows can affect nearby objects, occluding them from the light source. These shadows are usually harder and less subtle than form shadows, and they give us information about the location of the objects in our scene.
投射阴影 – 当对象或对象的一部分位于光源和另一个对象之间时创建的阴影。与仅影响同一对象的表单阴影不同,投射阴影可以影响附近的对象,从而将它们从光源中遮挡出来。这些阴影通常比形式阴影更硬,更不微妙,它们为我们提供了有关对象在场景中的位置的信息。


Ambient Occlusion: when an object gets close to another, light is less likely to reach the space in between objects, and that space looks darker. We can fake this effect by darkening these zones, usually in real-time environments as a cheap way of mimicking light bouncing around the scene, which is a very expensive effect. In reality, Ambient Occlusion is a mix of cast and form shadows, but we separate it in order to have more creative control over our scenes.
环境光遮蔽:当一个物体靠近另一个物体时,光线不太可能到达物体之间的空间,并且该空间看起来更暗。我们可以通过使这些区域变暗来伪造这种效果,通常在实时环境中作为模仿场景周围反射的光线的廉价方式,这是一种非常昂贵的效果。实际上,环境光遮蔽是投射阴影和形态阴影的混合体,但我们将其分开是为了对场景进行更具创造性的控制。


Much like multiple light sources can be combined together, shadows from multiple light sources can overlap and become darker.
就像多个光源可以组合在一起一样,来自多个光源的阴影可以重叠并变得更暗。
However, a single source of light cannot generate overlapping shadows (a mistake we sometimes make when drawing light). Each light source generates its own set of shadows. A form shadow and a cast shadow formed by the same light wouldn’t overlap, they would combine.
但是,单个光源不能产生重叠的阴影(我们在绘制光线时有时会犯这个错误)。每个光源都会生成自己的一组阴影。由同一光形成的形状阴影和投射阴影不会重叠,它们会结合在一起。


Shadows are not always dark.
阴影并不总是黑暗的。
Light bounces everywhere (thanks to indirect lighting). Some of this light will likely reach shadowed areas and bounce back to the viewer allowing us to see the color of areas in shade.
光线无处不在(得益于间接照明)。其中一些光线可能会到达阴影区域并反弹回观看者,从而使我们能够看到阴影区域的颜色。
The brightness of shadowed areas will depend on how much indirect light we have in our scene: in the desert, there is only one light source and no buildings, trees, or other objects that might bounce light and fill those shadows with color: we have very little indirect lighting (we will always have some), and shadows look dark and have very little color.
阴影区域的亮度将取决于场景中的间接光量:在沙漠中,只有一个光源,没有建筑物、树木或其他对象可能会反射光线并用颜色填充这些阴影:我们的间接照明很少(我们总是会有一些),阴影看起来很暗,颜色很少。


The shadow of this girl is very dark because there is only one light source (sun) and no surfaces where sunlight can bounce to fill it.
这个女孩的影子非常暗,因为只有一个光源(太阳),没有表面可以反射阳光来填充它。
On the other hand, during an overcast (cloudy) day, clouds bounce light everywhere, shadows get filled with the bouncing light, and we can even get to a point where shadows disappear.
另一方面,在阴天(阴天)期间,云层到处反射光线,阴影被反射光填充,我们甚至可以达到阴影消失的地步。


This woman has almost no shadow: the buildings, clouds, and rain are reflecting light everywhere.
这个女人几乎没有影子:建筑物,云彩和雨水到处反射光线。
When we have separate light sources casting shadows, these shadows can overlap. In real life, we mostly have one light source (the sun), so having several overlapping shadows from several light sources looks unnatural, and we usually try to avoid them or we try to soften those shadows.
当我们有单独的光源投射阴影时,这些阴影可以重叠。在现实生活中,我们大多只有一个光源(太阳),因此来自多个光源的几个重叠阴影看起来不自然,我们通常试图避免它们或尝试软化这些阴影。
These shadows overlap because we have multiple light sources, which looks unnatural.
这些阴影重叠,因为我们有多个光源,这看起来不自然:


In order to avoid this effect, lighting experts use larger sources of light that form softer shadows (such as windows or large lights) or use deflectors that scatter light in all directions.
为了避免这种影响,照明专家使用更大的光源来形成更柔和的阴影(例如窗户或大灯),或者使用向所有方向散射光线的偏转器。
Shadows can have smooth or hard edges.
阴影可以具有平滑或坚硬的边缘。
Cast shadows can have different degrees of border smoothness. I used to think that this depends on the distance between the shadow and the shadow-casting object, but I was slightly off.
投射阴影可以具有不同程度的边框平滑度。我曾经认为这取决于阴影和阴影投射对象之间的距离,但我有点偏离。
In the case of directional light, such as the sun, all light rays are parallel (the sun is so far away from the Earth that when light rays reach us they are almost parallel). This generates hard shadows:
在定向光的情况下,例如太阳,所有光线都是平行的(太阳离地球太远,以至于当光线到达我们时,它们几乎是平行的)。这将生成硬阴影:


However, when we have a light source that is closer to the object, shadows appear smoother.
但是,当我们有一个更接近物体的光源时,阴影看起来更平滑。
Once we get closer to the object, light rays approach the object at different angles, smoothing out the shadows. The furthest away from the light source, the smoother these shadows will get because light rays at the edges have traveled a longer distance and since they are traveling at slightly different angles, they separate more.
一旦我们靠近物体,光线就会以不同的角度接近物体,使阴影变得平滑。离光源越远,这些阴影就越平滑,因为边缘的光线传播的距离更长,并且由于它们以略微不同的角度传播,因此它们分离得更多。


For reference, the light rays from the sun are almost completely parallel but they do have a small variance of 1-1,5o so we should be able to see soft shadows from direct sunlight, especially at long distances from the shadow casting object. Increasing the size of the light source also softens shadows.
作为参考,来自太阳的光线几乎完全平行,但它们确实有1-1,5o的小方差,因此我们应该能够从阳光直射中看到柔和的阴影,特别是在距离阴影投射物体很远的地方。增加光源的大小也会软化阴影。


You might think that if sunlight rays are mostly parallel, a window would let light enter a room also as parallel rays. However, we also have to consider indirect light going through the window from all directions, as well as diffraction.
您可能会认为,如果阳光大部分是平行的,那么窗户也会让光线作为平行光线进入房间。但是,我们还必须考虑从各个方向穿过窗户的间接光,以及衍射。
Conclusion
结论
So, in this tutorial, we took a look at the main light effects that we should keep in mind when rendering a scene: emission, direct and indirect light bounces (both specular and diffuse), transmission, and absorption.
因此,在本教程中,我们来看看渲染场景时应牢记的主要光照效果:发射、直接和间接光反射(镜面反射和漫反射)、透射和吸收。
We also took a look at some related effects, such as metallic objects, refraction, and combining several light sources and shadows.
我们还研究了一些相关的效果,例如金属物体,折射以及组合多个光源和阴影。
Now that we have in mind the different parts that we need to render a scene, I would like to take a closer look at how we approach these different parts from a non-real-time approach (using ray tracing), a real-time approach (using rasterization), and an illustration approach (taking a look at the main shading techniques used in illustration).
现在我们已经想到了渲染场景所需的不同部分,我想仔细看看我们如何从非实时方法(使用光线追踪),实时方法(使用光栅化)和插图方法(看看插图中使用的主要着色技术)来处理这些不同部分。
This tutorial took me much longer than I thought, but I also learned a lot more than expected while researching it. I'm not sure how much time I'll need to finish each part, so wish me luck!
本教程花费的时间比我想象的要长得多,但是在研究它时,我也学到了比预期多得多的东西。我不确定我需要多少时间来完成每个部分,所以祝我好运!
Thank you for your time, and I hope it was useful. If you want to learn more about lighting, I strongly recommend taking a look at Light for Visual Artists by Richard Yot.
感谢您抽出宝贵时间,我希望它有用。如果你想了解更多关于照明的信息,我强烈建议你看看Richard Yot的《视觉艺术家的光》


评分

参与人数 3元素币 +32 活跃度 +27 展开 理由
aiko33 + 6 + 10 优秀
hogenxie + 17 + 7 资源哪里好,肯定元素找。
墨苍穹 + 9 + 10 太秀了吧?

查看全部评分

有时候,坚持了你最不想干的事情之后,会得到你最想要的东西。
使用道具 <
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表