青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

Shadow mapping

http://en.wikipedia.org/wiki/Shadow_map

From Wikipedia, the free encyclopedia

  (Redirected from Shadow map)
Jump to: navigation, search
Scene with shadow mapping
Scene with no shadows

Shadow mapping or projective shadowing is a process by which shadows are added to 3D computer graphics. This concept was introduced by Lance Williams in 1978, in a paper entitled "Casting curved shadows on curved surfaces". Since then, it has been used both in pre-rendered scenes, in realtime, and even in many console and high-end PC games. Shadow mapping is used by Pixar's RenderMan, and likewise, shadow mapping has been used in such films as Toy Story.

Shadows are created by testing whether a pixel is visible from the light source, by comparing it to a z-buffer or depth image of the light's view, stored in the form of a texture.

Contents

[hide]

[edit] Principle of a shadow and a shadow map

If you looked out from a source of light, all of the objects you can see would appear in light. Anything behind those objects, however, would be in shadow. This is the basic principle used to create a shadow map. The light's view is rendered, storing the depth of every surface it sees (the shadow map). Next, the regular scene is rendered comparing the depth of every point drawn (as if it were being seen by the light, rather than the eye) to this depth map.

For real-time shadows, this technique is less accurate than shadow volumes, but the shadow map can sometimes be a faster alternative depending on how much fill time is required for either technique in a particular application. As well, shadow maps do not require the use of an additional stencil buffer, and can sometimes be modified to produce shadows with a soft edge. However, unlike shadow volumes, the accuracy of a shadow map is limited by its resolution.

[edit] Algorithm overview

Rendering a shadowed scene involves two major drawing steps. The first produces the shadow map itself, and the second applies it to the scene. Depending on the implementation (and number of lights), this may require two or more drawing passes.

[edit] Creating the shadow map

Scene rendered from the light view.
Scene from the light view, depth map.

The first step renders the scene from the light's point of view. For a point light source, the view should be a perspective projection as wide as its desired angle of effect (it will be a sort of square spotlight). For directional light (e.g. that from the Sun), an orthographic projection should be used.

From this rendering, the depth buffer is extracted and saved. Because only the depth information is relevant, it is usual to avoid updating the color buffers and disable all lighting and texture calculations for this rendering, in order to save drawing time. This depth map is often stored as a texture in graphics memory.

This depth map must be updated any time there are changes to either the light or the objects in the scene, but can be reused in other situations, such as those where only the viewing camera moves. (If there are multiple lights, a separate depth map must be used for each light.)

In many implementations it is practical to render only a subset of the objects in the scene to the shadow map in order to save some of the time it takes to redraw the map. Also, a depth offset which shifts the objects away from the light may be applied to the shadow map rendering in an attempt to resolve stitching problems where the depth map value is close to the depth of a surface being drawn (i.e. the shadow casting surface) in the next step. Alternatively, culling front faces and only rendering the back of objects to the shadow map is sometimes used for a similar result.

[edit] Shading the scene

The second step is to draw the scene from the usual camera viewpoint, applying the shadow map. This process has three major components, the first is to find the coordinates of the object as seen from the light, the second is the test which compares that coordinate against the depth map, and finally, once accomplished, the object must be drawn either in shadow or in light.

[edit] Light space coordinates

Visualization of the depth map projected onto the scene

In order to test a point against the depth map, its position in the scene coordinates must be transformed into the equivalent position as seen by the light. This is accomplished by a matrix multiplication. The location of the object on the screen is determined by the usual coordinate transformation, but a second set of coordinates must be generated to locate the object in light space.

The matrix used to transform the world coordinates into the light's viewing coordinates is the same as the one used to render the shadow map in the first step (under OpenGL this is the product of the modelview and projection matrices). This will produce a set of homogeneous coordinates that need a perspective division (see 3D projection) to become normalized device coordinates, in which each component (x, y, or z) falls between -1 and 1 (if it is visible from the light view). Many implementations (such as OpenGL and Direct3D) require an additional scale and bias matrix multiplication to map those -1 to 1 values to 0 to 1, which are more usual coordinates for depth map (texture map) lookup. This scaling can be done before the perspective division, and is easily folded into the previous transformation calculation by multiplying that matrix with the following:

If done with a shader, or other graphics hardware extension, this transformation is usually applied at the vertex level, and the generated value is interpolated between other vertices, and passed to the fragment level.

[edit] Depth map test

Depth map test failures.

Once the light-space coordinates are found, the x and y values usually correspond to a location in the depth map texture, and the z value corresponds to its associated depth, which can now be tested against the depth map.

If the z value is greater than the value stored in the depth map at the appropriate (x,y) location, the object is considered to be behind an occluding object, and should be marked as a failure, to be drawn in shadow by the drawing process. Otherwise it should be drawn lighted.

If the (x,y) location falls outside the depth map, the programmer must either decide that the surface should be lit or shadowed by default (usually lit).

In a shader implementation, this test would be done at the fragment level. Also, care needs to be taken when selecting the type of texture map storage to be used by the hardware: if interpolation cannot be done, the shadow will appear to have a sharp jagged edge (an effect that can be reduced with greater shadow map resolution).

It is possible to modify the depth map test to produce shadows with a soft edge by using a range of values (based on the proximity to the edge of the shadow) rather than simply pass or fail.

The shadow mapping technique can also be modified to draw a texture onto the lit regions, simulating the effect of a projector. The picture above, captioned "visualization of the depth map projected onto the scene" is an example of such a process.

[edit] Drawing the scene

Final scene, rendered with ambient shadows.

Drawing the scene with shadows can be done in several different ways. If programmable shaders are available, the depth map test may be performed by a fragment shader which simply draws the object in shadow or lighted depending on the result, drawing the scene in a single pass (after an initial earlier pass to generate the shadow map).

If shaders are not available, performing the depth map test must usually be implemented by some hardware extension (such as GL_ARB_shadow), which usually do not allow a choice between two lighting models (lighted and shadowed), and necessitate more rendering passes:

  1. Render the entire scene in shadow. For the most common lighting models (see Phong reflection model) this should technically be done using only the ambient component of the light, but this is usually adjusted to also include a dim diffuse light to keep curved surfaces from appearing flat in shadow.
  2. Enable the depth map test, and render the scene lit. Areas where the depth map test fails will not be overwritten, and remain shadowed.
  3. An additional pass may be used for each additional light, using additive blending to combine their effect with the lights already drawn. (Each of these passes requires an additional previous pass to generate the associated shadow map.)

The example pictures in this article used the OpenGL extension GL_ARB_shadow_ambient to accomplish the shadow map process in two passes.

[edit] See also

[edit] External links

[edit] Further reading

posted on 2008-12-22 14:49 zmj 閱讀(1517) 評論(0)  編輯 收藏 引用

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            日韩网站在线观看| 亚洲乱码国产乱码精品精98午夜| 亚洲欧美激情一区| 亚洲精品韩国| 欧美在线观看一二区| 国产精品私人影院| 久久精品国产综合精品| 久久久久久久久久久成人| 亚洲韩国一区二区三区| 一本大道久久精品懂色aⅴ| 国产精品免费一区二区三区观看| 伊人激情综合| 亚洲人屁股眼子交8| 欧美性大战久久久久久久| 久久成人精品| 免费日韩精品中文字幕视频在线| 欧美亚日韩国产aⅴ精品中极品| 在线视频国产日韩| 欧美亚洲自偷自偷| 久久亚洲美女| 国产视频精品va久久久久久| 另类欧美日韩国产在线| 亚洲一区免费| 欧美日韩在线一区| 久久久久久噜噜噜久久久精品| 一区二区免费在线播放| 国产一区二区视频在线观看 | 欧美日韩在线看| 亚洲成人资源网| 一本一道久久综合狠狠老精东影业 | 亚洲美女视频在线观看| 国产一区二区三区成人欧美日韩在线观看 | 一本色道久久| 亚洲激情亚洲| 久久国产精品久久久久久电车| 国产精品久线观看视频| 亚洲第一精品福利| 国产亚洲欧美一区二区三区| 久久精品成人| 国产精品福利av| 亚洲一区二区三区欧美| 亚洲毛片在线观看| 亚洲国产视频直播| 亚洲国产精品123| 国产一区二区成人久久免费影院| 久久成人免费电影| 午夜精品国产更新| 亚洲视频一二区| 欧美激情bt| 亚洲国产精品久久久久秋霞不卡| 欧美精品亚洲二区| 欧美高清视频在线| 亚洲高清在线观看| 久热精品视频| 欧美成人嫩草网站| 欧美日韩亚洲成人| 午夜激情亚洲| 久久成人亚洲| 另类人畜视频在线| 欧美人与禽性xxxxx杂性| 欧美高清在线视频| 91久久夜色精品国产九色| 亚洲精品美女在线| 亚洲精品综合精品自拍| 欧美成人午夜激情在线| 最新成人在线| 一区二区av在线| 欧美日韩成人综合在线一区二区| 午夜精品亚洲| 国产日韩精品视频一区二区三区| 欧美69视频| 亚洲黄页一区| 亚洲男人影院| 久久久久久91香蕉国产| 欧美极品aⅴ影院| 亚洲精品国产欧美| 亚洲一区二区在线免费观看视频 | 国产欧美日韩三级| 亚洲二区视频| 国产欧美精品国产国产专区| 亚洲欧美经典视频| 夜夜嗨av色综合久久久综合网| 在线综合亚洲欧美在线视频| 亚洲欧美在线一区二区| 国产真实乱偷精品视频免| 91久久久久久| 韩国免费一区| 免费观看成人网| 久久激情一区| 欧美无砖砖区免费| 午夜精品久久| 欧美国产高清| 香蕉精品999视频一区二区| 国内免费精品永久在线视频| 99视频一区二区三区| 欧美一区二区性| 欧美日韩中文精品| 亚洲国产国产亚洲一二三| 国产一区二区三区成人欧美日韩在线观看 | 欧美日韩大片| 亚洲国产精品va| 香蕉久久夜色精品国产使用方法| 黄网站免费久久| 欧美日韩一区二区欧美激情| 久久动漫亚洲| 一本色道久久加勒比精品 | 一本高清dvd不卡在线观看| 久久夜色精品国产亚洲aⅴ| 最新中文字幕亚洲| 久久亚洲春色中文字幕| 亚洲视频大全| 欧美四级在线观看| 久久综合九九| 免费成人你懂的| 亚洲欧美日韩天堂| 亚洲日本电影| 欧美日韩国产在线播放| 久久久久九九九九| 免费日韩一区二区| 午夜日韩激情| 亚洲一级一区| 日韩视频精品在线| 欧美色网在线| 亚洲五月六月| 亚洲精品日日夜夜| 亚洲二区视频| 亚洲综合色激情五月| 亚洲人成网站在线播| 在线激情影院一区| 欧美久久影院| 99国产精品久久久久久久| 亚洲精华国产欧美| 免费欧美网站| 一区二区三区**美女毛片| 欧美二区在线观看| 亚洲国产成人tv| 女生裸体视频一区二区三区| 久久久亚洲国产天美传媒修理工 | 欧美一区免费视频| 午夜在线播放视频欧美| 国产亚洲精品久久久久久| 国产精品久久久久久久久借妻 | 久久一本综合频道| 美女精品网站| 9人人澡人人爽人人精品| 亚洲视频在线观看视频| 一区二区三区日韩精品视频| 日韩视频在线免费观看| 一本久久a久久免费精品不卡| 亚洲人成绝费网站色www| 国产精品高潮呻吟久久av无限| 亚洲欧美成人精品| 香蕉av777xxx色综合一区| 欧美国产亚洲精品久久久8v| 欧美成人午夜激情视频| 欧美激情综合| 久久久噜噜噜久久| 久久全球大尺度高清视频| 欧美黑人多人双交| 亚洲欧洲综合| 亚洲婷婷综合久久一本伊一区| 亚洲免费视频成人| 亚洲精品在线观看视频| 久久嫩草精品久久久精品一| 日韩视频在线观看| 亚洲影视中文字幕| 亚洲国产精品成人va在线观看| 亚洲欧洲精品一区二区| 一本色道久久综合亚洲精品婷婷| 韩国av一区二区| 亚洲激情视频在线| 亚洲欧美电影院| 日韩午夜在线观看视频| 亚洲一二三区精品| 麻豆免费精品视频| 日韩午夜电影av| 久久久久久噜噜噜久久久精品 | 快播亚洲色图| 欧美一级久久久| 欧美v日韩v国产v| 国产精品毛片a∨一区二区三区| 欧美成人午夜剧场免费观看| 欧美午夜视频网站| 欧美日韩亚洲一区二区三区| 国产一区二区三区免费不卡| 亚洲精品在线免费| 亚洲精品国产精品国自产在线| 亚洲欧美日韩一区二区在线| 欧美jizz19性欧美| 美女精品在线| 亚洲午夜久久久久久久久电影院| 久久女同精品一区二区| 久久精品国产99精品国产亚洲性色| 欧美激情久久久久久| 欧美成人国产一区二区| 国产日韩在线视频| 亚洲天堂av在线免费| 亚洲国产精品久久久久秋霞蜜臀 | 欧美另类69精品久久久久9999| 奶水喷射视频一区|