This article  needs additional citations for  verification . Please help  improve this article  by  adding citations to reliable sources . Unsourced material may be challenged and removed.
Find sources:   "Shading"  –  news   ·   newspapers   ·   books   ·   scholar   ·   JSTOR   (May 2007)  ( Learn how and when to remove this message )
Flat shading  describes a number of simple lighting techniques. In this case, the lighting value is determined once for each face. The color value can also be determined per object or per vertex.
Gouraud shading  (1971) improved the appearance of curved objects.
Phong shading   interpolation  is a more realistic shading technique developed by  Bui Tuong Phong  in 1973.

Shading  refers to the depiction of  depth perception  in  3D models  (within the field of  3D computer graphics ) or  illustrations  (in  visual art ) by varying the level of  darkness . [1]  Shading tries to approximate local behavior of  light  on the object's surface and is not to be confused with techniques of adding shadows, such as  shadow mapping  or  shadow volumes , which fall under global behavior of light.
::阴影是指在3D模型 (在3D计算机图形领域) 或插图 (在视觉艺术中) 中通过改变黑暗水平来描绘深度感知. [1]阴影试图在物体表面近似地描述光的局部行为,不应与添加阴影的技术混,例如阴影映射或阴影体积,这些技术属于光的全球行为.

In drawing
::在绘画中

Shading  is used traditionally in  drawing  for depicting a range of darkness by applying media more densely or with a darker shade for darker areas, and less densely or with a lighter shade for lighter areas. Light patterns, such as objects having light and shaded areas, help when creating the illusion of depth on paper. [2] [3]
::阴影是传统上用于绘画,用于描绘一系列的黑暗,通过将媒体应用更密集或更深的阴影用于更深的区域,以及更轻的区域的较轻的阴影.光图案,如具有光和阴影区域的物体,有助于在纸上创造深度的错觉. [1] [2]

There are various techniques of shading, including  cross hatching , where perpendicular lines of varying closeness are drawn in a grid pattern to shade an area. The closer the lines are together, the darker the area appears. Likewise, the farther apart the lines are, the lighter the area appears.
::阴影的各种技术,包括交叉化,在一个区域的阴影的网格图案中绘制出不同近距离的垂直线.线条越近,区域看起来越暗.同样,线条越远,区域看起来越亮.

Powder shading  is a  sketching  shading method. In this style,  stumping powder  and paper  stumps  are used to draw a picture. (This is also in color.) The stumping powder is smooth and doesn't have any shiny particles. The paper to be used should have small grains on it so that the powder remains on the paper.
::粉末遮是一种草图遮方法.在这种风格中,使用粉和纸来绘制图片. (这也在颜色中).粉是光滑的,没有任何闪闪发光的颗粒.使用的纸上应该有小粒,这样粉末就会留在纸上.在这种情况下,粉末的表面会被涂抹,使得粉末的表面变得光滑.在这种情况下,粉末的表面会被涂抹,使得粉末的表面变得光亮.

In computer graphics
::在计算机图形学

Picture of sphere
Gouraud shading , developed by  Henri Gouraud  in 1971, was one of the first shading techniques developed for  3D computer graphics .
Picture of sixteen rope knots
A knot shaded with different  materials  including aluminum, brass, bronze, copper, electrum, gold, iron, pewter, silver, clay, foil, glaze, plastic, rubber, satin, and velvet. created in  Mathematica  13.1

In  computer graphics , shading refers to the process of altering the color of an object/surface/polygon in the 3D scene, based on things like (but not limited to) the surface's angle to lights, its distance from lights, its angle to the camera and material properties (e.g.  bidirectional reflectance distribution function ) to create a  photorealistic  effect.
::在计算机图形学中,遮光是指在3D场景中改变对象/表面/多边形的颜色的过程,基于诸如 (但不限于) 表面与光的角度,光距离,与相机的角度以及材料特性 (例如双向反射分布函数) 来创建光现实效应.

Shading is performed during the  rendering  process by a program called a  shader .
::染色过程中,一个叫做遮光器的程序会进行遮光.

Surface angle to a light source
::表面与光源的角度

Shading alters the colors of faces in a 3D model based on the angle of the surface to a light source or light sources.
::阴影改变面部颜色在3D模型中,基于表面对光源或光源的角度.

The first image below has the faces of the box rendered, but all in the same color. Edge lines have been rendered here as well which makes the image easier to see.
::下面的第一张图片是对方的染,但都是相同的颜色. 这里边缘线也被染,使图像更容易看到.

The second image is the same model rendered without edge lines. It is difficult to tell where one face of the box ends and the next begins.
::第二张图像是同样的模型,没有边缘线.很难分辨盒子的一面在哪里结束,下一个在哪里开始.

The third image has shading enabled, which makes the image more realistic and makes it easier to see which face is which.
::让图像更真实,更容易看到哪张脸是哪张.

Rendered image of a box. This image has no shading on its faces, but instead uses  edge lines  (also known as  wireframe ) to separate the faces and a bolder  outline  to separate the object from the background.
This is the same object with the lines removed; the only indication of the interior geometry are the points of the object's  silhouette .
This is the same object rendered with  flat shading . The color of the 3 visible front faces has been set based on their angle (determined by the  normal vector ) to the light sources.

Types of lighting
::照明类型

Shading effects from a  floodlight  using a  ray tracer

When a shader computes the result color, it uses a  lighting model  to determine the amount of light reflected at specific points on the surface. Different lighting models can be combined with different shading techniques — while lighting says how much light is reflected, shading determines how this information is used in order to compute the final result. It may for example compute lighting only at specific points and use  interpolation  to fill in the rest. The shader may also decide about how many light sources to take into account etc.
::当遮光器计算结果颜色时,它使用照明模型来确定表面上特定点反射的光量.不同的照明模型可以与不同的遮光技术相结合. 虽然照明表示反射的光量,但遮光决定了如何使用这些信息来计算最终结果.例如,它可能只计算特定点的照明,并使用插值来填充其余部分.遮光器也可以决定要考虑多少光源等.

Ambient lighting
::环境照明

An ambient light source represents an omnidirectional, fixed-intensity and fixed-color light source that affects all objects in the scene equally (is omnipresent). During rendering, all objects in the scene are brightened with the specified intensity and color. This type of light source is mainly used to provide the scene with a basic view of the different objects in it. This is the simplest type of lighting to implement, and models how light can be scattered or  reflected  many times, thereby producing a uniform effect.
::环境光源是一种全向,固定强度和固定颜色的光源,它对场景中的所有物体均有影响 (无处不在).在染过程中,场景中的所有物体都以指定强度和颜色亮化.这种类型的光源主要用于为场景提供不同物体的基本视图.这是实现的最简单的照明类型,并模拟光如何被分散或反射多次,从而产生统一的效果.

Ambient lighting can be combined with  ambient occlusion  to represent how exposed each point of the scene is, affecting the amount of ambient light it can reflect. This produces diffused, non-directional lighting throughout the scene, casting no clear shadows, but with enclosed and sheltered areas darkened. The result is usually visually similar to an overcast day.
::环境照明可以与环境遮蔽相结合,以表示场景的每个点的暴露程度,影响它可以反射的环境光的量.这会在整个场景中产生分散的,非方向的照明,不会投射明确的阴影,但封闭和保护区域会变暗.结果通常与阴天相似.

Point lighting
::点灯

Light originates from a single  point  and spreads outward in all directions.
::它们在光线上产生光线,

Spotlighting
::聚焦

Models a  spotlight : light originates from a single point and spreads outward in a  cone .
::模拟聚光灯:光源来自一个单点,并以形向外传播.

Area lighting
::区域照明

Light originates from a small area on a single  plane . (A more realistic model than a point light source.)
::光源来自单一平面上的一个小区域. (比点光源更现实的模型.)

Directional lighting
::方向照明

A directional light source illuminates all objects equally from a given  direction , like an area light of infinite size and infinite distance from the scene; there is shading, but cannot be any distance falloff. This is like the  sun .
::定向光源从给定的方向均等地照亮所有物体,就像一个区域光线的无限大小和无限距离场景;有阴影,但不能有任何距离落差.这就像太阳.

Distance falloff
::距离落差

Two boxes rendered with  OpenGL  (Note that the color of the two front faces is the same even though one is farther away.)
The same model rendered using  ARRIS CAD , which implements  distance falloff  to make surfaces that are closer to the eye brighter

Theoretically, two surfaces which are  parallel  are illuminated virtually the same amount from a  distant  unblocked light source such as the sun. The distance falloff effect produces images which have more shading and so would be realistic for proximal light sources.
::理论上,两个平行的表面从远处的未阻的光源 (如太阳) 获得几乎相同的照明量.距离落差效应产生了更多阴影的图像,因此对于近距离光源来说是现实的.

The left image doesn't use distance falloff. Notice that the colors on the front faces of the two boxes are  exactly  the same. It may appear that there is a slight difference where the two faces directly overlap, but this is an  optical illusion  caused by the vertical edge below where the two faces meet.
::左图没有使用距离落差.请注意,两个盒子的前面颜色完全相同.这两个面直接重叠的地方可能会出现微小的差异,但这是由下面的垂直边缘造成的光学错觉,两个面相遇的地方.

The right image does use distance falloff. Notice that the front face of the closer box is brighter than the front face of the back box. Also, the floor goes from light to dark as it gets farther away.
::右图确实使用了距离落差.请注意,靠近盒子的前面比后面的前面更亮.此外,地板越远,就会从亮变暗.

Calculation
::计算方式

Distance falloff can be calculated in a number of ways:
::落差距可以通过多种方式计算:

  • Power of the distance  – For a given point at a distance  x  from the light source, the light intensity received is proportional to 1/ x n .
    • None  ( n  = 0) – The light intensity received is the same regardless of the distance between the point and the light source.
      ::无 (n = 0) 无论点与光源之间的距离如何,所接收的光强度都是相同的.
    • Linear  ( n  = 1) – For a given point at a distance  x  from the light source, the light intensity received is proportional to 1/ x .
      ::线性 (n = 1) 对于一个与光源 x 距离的给定点,所接收的光强度与 1/x 相称.
    • Quadratic  ( n  = 2) – This is how light intensity decreases in reality if the light has a free path (i.e. no  fog  or any other thing in the air that can  absorb  or  scatter  the light). For a given point at a distance  x  from the light source, the light intensity received is proportional to 1/ x 2 .
      ::平方 (n = 2) 如果光有自由路径 (即没有雾或空气中的任何其他物体可以吸收或散射光),光强度实际上会这样减少.对于一个与光源相距x的给定点,所接收的光强度与1/x2成比例.

    ::距离的强度 对于距离光源的某一点x处的某一点,所接收的光强度是与1/xn成比例的. 无 (n = 0) 所接收的光强度是不论点与光源之间的距离相同的. 线性 (n = 1) 对于距离光源的某一点x处的某一点,所接收的光强度是与1/x成比例的. 平方 (n = 2) 如果光线有自由路径 (即没有雾或空气中任何可以吸收或散射光线的物体),光强度实际上是这样降低的. 对于距离光源的某一点x处的某一点,所接收的光强度是与1/x2成比例的.
  • Any number of other  mathematical functions  may also be used.
    ::任何其他数学的函数也可以使用.

Shading techniques
::遮阳技术

During shading a  surface normal  is often needed for lighting computation. The normals can be precomputed and stored for each vertex of the model.
::在遮光时,通常需要表面正常来进行照明计算.对于模型的每个顶点,可以预先计算并存储正常值.

Flat shading
::平的阴影

Flat shading a  textured   cuboid
graphics complex of a seashell with flat shading modeled in Mathematica
Graphics complex of a seashell with flat shading modeled in Mathematica

Here, the lighting is evaluated only once for each polygon (usually for the first vertex in the polygon, but sometimes for the  centroid  for triangle meshes), based on the polygon's surface normal and on the assumption that all polygons are flat. The computed color is used for the whole polygon, making the corners look sharp. This is usually used when more advanced shading techniques are too computationally expensive.  Specular  highlights are rendered poorly with flat shading: If there happens to be a large specular component at the representative vertex, that brightness is drawn uniformly over the entire face. If a specular highlight doesn't fall on the representative point, it is missed entirely. Consequently, the specular reflection component is usually not included in flat shading computation.
::在这里,每个多边形的照明仅一次 (通常是多边形中的第一个顶点,但有时是三角形网格的中心点),基于多边形的表面正常,并假定所有多边形都是平的.计算的颜色用于整个多边形,使角形看起来很利.这通常用于更先进的阴影技术在计算上太昂贵. 镜面亮点在平面阴影中呈现不佳:如果在代表顶点上碰巧有一个大的镜面组件,那么亮度会在整个面部均地绘制.如果镜面亮点不落在代表点上,它就会完全错过.因此,镜面反射组件通常不会被纳入平面阴影计算中.

Smooth shading
::顺的遮阳

In contrast to flat shading where the colors change discontinuously at polygon borders, with smooth shading the color changes from pixel to pixel, resulting in a smooth color transition between two adjacent polygons. Usually, values are first calculated in the vertices and  bilinear interpolation  is used to calculate the values of pixels between the vertices of the polygons. Types of smooth shading include  Gouraud shading [4]  and  Phong shading . [5]
::与平面遮蔽不同,在多边形边界上颜色不连续地变化,在光滑遮蔽中颜色从像素到像素变化,导致两个相邻的多边形之间光滑的颜色过渡.通常,值首先计算在顶点中,并使用双线插值计算多边形顶点之间的像素值.光滑遮蔽的类型包括Gouraud遮蔽[4]和Phong遮蔽.[5]

Gouraud shading
::色的阴影
  1. Determine the normal at each polygon vertex.
    ::确定每个多边形顶点的正常值.
  2. Apply an  illumination model  to each vertex to calculate the light intensity from the vertex normal.
    ::应用一个照明模型到每个顶点,以计算顶点正常的光强度.
  3. Interpolate the vertex intensities using  bilinear interpolation  over the surface polygon.
    ::在表面多边形上使用双线式插入,插入顶点强度.

Problems:
::问题:

  • Due to lighting being computed only at vertices, the inaccuracies (especially of specular highlights on large triangles) can become too apparent.
    ::由于光线仅在顶点计算,不准确性 (特别是大三角形上的光线亮点) 可能变得太明显.
  • T-junctions with adjoining polygons can sometimes result in visual anomalies. In general, T-junctions should be avoided.
    ::有时与相邻的多边形的T结会会导致视觉异常.一般来说,应避免T结.
Phong shading
::影

Phong shading is similar to Gouraud shading, except that instead of interpolating the light intensities the normals are interpolated between the vertices and the lighting is evaluated per-pixel. Thus, the specular highlights are computed much more precisely than in the Gouraud shading model.
::影与古劳影相似,但除了插入光强度,正常值在顶点之间被插入,并且每像素评估照明.因此,镜面亮点比古劳影模计算得更精确.

  1. Compute a normal N for each vertex of the polygon.
    ::计算多边形的每个顶点的正常N.
  2. Using  bilinear interpolation  compute a normal, N i  for each pixel. (Normal has to be renormalized each time.)
    ::使用双线插值计算每个像素的正常,Ni. (正常必须每次重新规范化).
  3. Apply an  illumination model  to each pixel to calculate the light intensity from N i .
    ::应用一个照明模型到每个像素来计算Ni的光强度.

Deferred shading
::延迟遮

Deferred shading  is a shading technique by which computation of shading is deferred to later stage by rendering in two passes, potentially increasing performance by not discarding expensively shaded pixels. The first pass only captures surface parameters (such as depth, normals and material parameters), the second one performs the actual shading and computes the final colors. [6] [7] [8] : 884 
::延迟遮是一种遮技术,通过两次染将遮计算推迟到后期阶段,通过不丢弃昂贵的遮像素,可能提高性能.第一个通过只捕获表面参数 (如深度,正常和材料参数),第二个执行实际遮并计算最终颜色. [1] [2] [3]: 884

Other approaches
::其他方法

Both  Gouraud shading  and  Phong shading  can be implemented using  bilinear interpolation . Bishop and Weimer  [9]  proposed to use a  Taylor series  expansion of the resulting expression from applying an  illumination model  and bilinear interpolation of the normals. Hence, second-degree  polynomial interpolation  was used. This type of biquadratic interpolation was further elaborated by Barrera et al., [10]  where one second-order polynomial was used to interpolate the diffuse light of the  Phong reflection model  and another second-order polynomial was used for the specular light.
::戈劳影和影都可以使用双线性插入来实现.比索和韦默 [9] 建议使用泰勒数列扩展,将照明模型和正常的双线性插入应用到得到的表达式中.因此,使用了二度多项式插入.这种类型的二次方位插入进一步由巴雷拉等人阐述, [10] 其中一个二次多项式用于插入反射模型的分散光,另一个二次多项式用于光镜.

Spherical linear interpolation ( Slerp ) was used by Kuij and Blake [11]  for computing both the normal over the polygon, as well as the vector in the direction to the light source. A similar approach was proposed by Hast, [12]  which uses  quaternion  interpolation of the normals with the advantage that the normal will always have unit length and the computationally heavy normalization is avoided.
::球形线性插入 (Slerp) 是库伊和布莱克使用的[11],用于计算多边形上的正常值,以及向量向光源的方向.哈斯特提出了类似的方法,[12]它使用常数的四边分插入,优点是常数总是具有单位长度,并且避免了计算重的正常化.

Flat vs. smooth shading
::平面与光滑的阴影

Flat Smooth
Uses the same color for every pixel in a face – usually the color of the first vertex Smooth shading uses linear interpolation of either colors or normals between vertices
Edges appear more pronounced than they would on a real object because in reality almost all edges are somewhat round The edges disappear with this technique
Same color for any point of the face Each point of the face has its own color
Individual faces are visualized underlying surface are visualized
Not suitable for smooth objects Suitable for any objects
Less computationally expensive More computationally expensive

Computer vision
::计算机视觉

" Shape from shading " reconstruction

In  computer vision , some methods for  3D reconstruction  are based on shading, or  shape-from-shading . Based on an image's shading, a three-dimensional model can be reconstructed from a single photograph. [13]
::在计算机视觉中,一些3D重建方法是基于遮蔽或从遮蔽中形成的.根据图像的遮蔽,可以从单张照片中重建一个三维模型. [1]

Last modified: Wednesday, 19 March 2025, 10:05 PM