//-----------------------------------------------------------------------------
// 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.
<Enter> Starts and stops the scene
<Space> Advances the scene by a small increment
<F1> Shows help or available commands.
<F2> Prompts user to select a new rendering device or display mode
<Alt+Enter> Toggles between fullscreen and windowed modes
<Esc> 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
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
《3D游戏编程》随书光盘 12章: 设计阴影的多种技巧 (120个子文件)
Shadow.aps 62KB
compile.bat 37B
compile.bat 37B
hiah.bmp 768KB
seafloor.bmp 65KB
seafloor.bmp 65KB
bihull.bmp 65KB
tiger.bmp 65KB
tiger.bmp 65KB
wings.bmp 17KB
white.bmp 12KB
white.bmp 12KB
d3dapp.cpp 60KB
d3dapp.cpp 60KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
dxutil.cpp 37KB
d3dsettings.cpp 36KB
d3dsettings.cpp 36KB
ShadowVolume.cpp 27KB
d3denumeration.cpp 26KB
d3denumeration.cpp 26KB
d3dfont.cpp 26KB
d3dfont.cpp 26KB
Shadow.cpp 25KB
d3dutil.cpp 25KB
d3dutil.cpp 25KB
d3dfile.cpp 24KB
d3dfile.cpp 24KB
d3dfile.cpp 24KB
d3dfile.cpp 24KB
Shadow.cpp 22KB
main.cpp 21KB
main.cpp 19KB
ZFrustum.cpp 6KB
ZFrustum.cpp 6KB
ZCamera.cpp 3KB
ZCamera.cpp 3KB
ZFLog.cpp 2KB
ZFLog.cpp 2KB
ShadowVolume.dsp 5KB
Shadow.dsp 5KB
Shadow.dsp 5KB
BasicFrame.dsp 5KB
BasicFrame.dsp 5KB
ShadowVolume.dsw 547B
BasicFrame.dsw 543B
BasicFrame.dsw 543B
Shadow.dsw 535B
Shadow.dsw 535B
Shadow.exe 580KB
ShadowVolume.exe 536KB
Shadow.exe 532KB
BasicFrame.exe 528KB
BasicFrame.exe 528KB
shadow.fx 1KB
shadow.fx 1KB
shadow.fx 1002B
dxutil.h 8KB
dxutil.h 8KB
dxutil.h 8KB
dxutil.h 8KB
d3dutil.h 7KB
d3dutil.h 7KB
d3dapp.h 7KB
d3dapp.h 7KB
d3dsettings.h 5KB
d3dsettings.h 5KB
d3denumeration.h 5KB
d3denumeration.h 5KB
d3dfile.h 4KB
d3dfile.h 4KB
d3dfile.h 4KB
d3dfile.h 4KB
define.h 3KB
define.h 3KB
Shadow.h 3KB
Shadow.h 3KB
d3dfont.h 3KB
d3dfont.h 3KB
ZCamera.h 2KB
ZCamera.h 2KB
resource.h 1KB
resource.h 1KB
resource.h 1KB
ZFrustum.h 1KB
ZFrustum.h 1KB
ZFLog.h 860B
ZFLog.h 860B
DirectX.ico 25KB
DirectX.ico 25KB
ShadowVolume.jpg 16KB
panda.jpg 5KB
panda.jpg 5KB
ShadowVolume.manifest 689B
plane.max 127KB
plane.max 127KB
Shadow.ncb 145KB
Shadow.opt 49KB
共 120 条
- 1
- 2
资源评论
- WentaoSun2015-09-01这本书不错的。推荐一下
- Beginner_Tom2014-02-21还不错!!挺好的!
hhh_hao
- 粉丝: 25
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功