Chap12
所属分类:3D图形编程
开发工具:Visual C++
文件大小:1973KB
下载次数:17
上传日期:2009-03-28 16:08:10
上 传 者:
hhh_hao
说明: 《3D游戏编程》随书光盘 12章: 设计阴影的多种技巧, 有详细源代码, 包括平面阴影, 投影阴影及阴影体技巧。
(" 3D Game Programming" book with CD-ROM Chapter 12: Design a shadow of a wide range of skills, there is a detailed source code, including the plane the shadow of the shadow and the shadow of the projector body skills.)
文件列表:
Chap12\01.PlanarShadow\d3dapp.cpp (61247, 2003-08-05)
Chap12\01.PlanarShadow\d3dapp.h (6881, 2003-08-05)
Chap12\01.PlanarShadow\d3denumeration.cpp (26684, 2003-08-05)
Chap12\01.PlanarShadow\d3denumeration.h (5140, 2003-08-05)
Chap12\01.PlanarShadow\d3dfile.cpp (24890, 2003-08-05)
Chap12\01.PlanarShadow\d3dfile.h (4232, 2003-08-05)
Chap12\01.PlanarShadow\d3dfont.cpp (26473, 2003-08-05)
Chap12\01.PlanarShadow\d3dfont.h (2582, 2003-08-05)
Chap12\01.PlanarShadow\d3dsettings.cpp (37141, 2003-08-05)
Chap12\01.PlanarShadow\d3dsettings.h (5437, 2003-08-05)
Chap12\01.PlanarShadow\d3dutil.cpp (25393, 2003-08-05)
Chap12\01.PlanarShadow\d3dutil.h (7172, 2003-08-05)
Chap12\01.PlanarShadow\data\plane.max (129536, 2003-08-05)
Chap12\01.PlanarShadow\data\plane.X (1694, 2003-08-05)
Chap12\01.PlanarShadow\data\seafloor.bmp (66616, 2002-11-12)
Chap12\01.PlanarShadow\data\seafloor.x (145017, 2002-11-12)
Chap12\01.PlanarShadow\data\tiger.bmp (66614, 2002-11-12)
Chap12\01.PlanarShadow\data\tiger.x (29453, 2002-11-12)
Chap12\01.PlanarShadow\DirectX.ico (25214, 2003-08-05)
Chap12\01.PlanarShadow\dxutil.cpp (37459, 2003-08-05)
Chap12\01.PlanarShadow\dxutil.h (8220, 2003-08-05)
Chap12\01.PlanarShadow\resource.h (1433, 2003-08-05)
Chap12\01.PlanarShadow\Shadow.cpp (23012, 2005-12-18)
Chap12\01.PlanarShadow\Shadow.dsp (5463, 2003-08-05)
Chap12\01.PlanarShadow\Shadow.dsw (535, 2003-08-05)
Chap12\01.PlanarShadow\Shadow.exe (544768, 2003-08-05)
Chap12\01.PlanarShadow\Shadow.h (2818, 2005-12-18)
Chap12\01.PlanarShadow\Shadow.rc (5638, 2003-08-05)
Chap12\02.ProjectiveImage\BasicFrame.dsp (4868, 2003-08-08)
Chap12\02.ProjectiveImage\BasicFrame.dsw (543, 2003-05-25)
Chap12\02.ProjectiveImage\BasicFrame.exe (540672, 2003-08-09)
Chap12\02.ProjectiveImage\compile.bat (37, 2003-08-08)
Chap12\02.ProjectiveImage\d3dfile.cpp (24890, 2003-08-05)
Chap12\02.ProjectiveImage\d3dfile.h (4232, 2003-08-05)
Chap12\02.ProjectiveImage\define.h (3206, 2003-07-20)
Chap12\02.ProjectiveImage\dxutil.cpp (37459, 2003-08-05)
Chap12\02.ProjectiveImage\dxutil.h (8220, 2003-08-05)
Chap12\02.ProjectiveImage\hiah.bmp (786488, 2003-08-07)
Chap12\02.ProjectiveImage\main.cpp (19461, 2005-12-18)
Chap12\02.ProjectiveImage\panda.jpg (5435, 2003-07-14)
... ...
//-----------------------------------------------------------------------------
// Name: ShadowVolume Direct3D Sample
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
Description
===========
The ShadowVolume sample uses stencil buffers to implement real-time shadows.
In the sample, a complex object is rendered and used as a shadow-caster, to
cast real-time shadows on itself and on the terrain below.
Stencil buffers are a depth buffer technique that can be updated as
geometry is rendered, and used again as a mask for drawing more geometry.
Common effects include mirrors, shadows (an advanced technique), dissolves,
etc..
Note that not all cards support all features for all the various stencil
buffer techniques (some hardware has no, or limited, stencil buffer
support). For more information on stencil buffers, refer to the DirectX SDK
documentation.
Path
====
Source: DXSDK\Samples\C++\Direct3D\StencilBuffer\ShadowVolume
Executable: DXSDK\Samples\C++\Direct3D\Bin
User's Guide
============
The following keys are implemented. The dropdown menus can be used for the
same controls.
Starts and stops the scene
Advances the scene by a small increment
Shows help or available commands.
Prompts user to select a new rendering device or display mode
Toggles between fullscreen and windowed modes
Exits the app.
Programming Notes
=================
Real-time shadows is a fairly advanced technique. Each frame, or as the
geometry or lights in the scene are moves, an object called a shadow volume
is computed. A shadow volume is an actual 3D object which is the siholuette
of the shadowcasting object, as pretruded away from the light source.
In this sample, the 3D object which casts shadows is a bi-plane. Each frame,
the sihlouette of the plane is computed (using an edge detection algorithm,
in which sihlouette edges are found because the normals of adjacent polygons
will have opposing normals with respect to the light vector). The resulting
edge list (the sihlouette) is pretuded into a 3D object away from the light
source. This 3D object is known as the shadow volume, as everypoint inside
the volume is inside a shadow.
Next, the shadow volume is rendering into the stencil buffer twice. First,
only forward-facing polygons are rendering, and the stencil buffer values
are incremented each time. Then the back-facing polygons of the shadow
volume are drawm, decrementing values in the stencil buffer. Normally, all
incremented and decremented values would cancel each other out. However,
because the scene was already rendered with normal geometry (the plane and
the terrain, in this case), some pixels will fail the zbuffer test as the
shadowvolume is rendered. Any values left in the stencil buffer correspond
to pixels that are in the shadow.
Finally, these remaining stencil buffer contents are used as a mask, as a
large all-encompassing black quad is alpha-blended into the scene. With the
stencil buffer as a mask, only pixels in shadow are darkened
This sample makes use of common DirectX code (consisting of helper functions,
etc.) that is shared with other samples on the DirectX SDK. All common
headers and source code can be found in the following directory:
DXSDK\Samples\C++\Common
近期下载者:
相关文件:
收藏者: