ShadowShader

所属分类:DirextX编程
开发工具:Visual C++
文件大小:3059KB
下载次数:71
上传日期:2008-05-30 01:03:17
上 传 者sxf19
说明:  DirectX 阴影的例子 -- ShadowShader Direct3D Sample
(DirectX example of the shadow of ShadowShader Direct3D Sample)

文件列表:
ATI.ico (4534, 2001-11-09)
Media (0, 2001-12-06)
Media\Basketball.bmp (1572920, 2001-04-26)
Media\Basketball_Bump.bmp (525368, 2001-04-26)
Media\ChaliceUV_bump.bmp (786488, 2001-07-12)
Media\ChaliceUV_RGB.bmp (786488, 2001-07-09)
Media\earth.bmp (393270, 2000-09-22)
Media\EarthLights.bmp (393272, 2001-02-27)
Media\Fieldstone.tga (197147, 2001-03-25)
Media\FieldstoneDOT3.tga (197147, 2001-03-25)
Media\Soccer1.bmp (1572920, 2001-04-26)
Media\Soccer_Bump.bmp (525368, 2001-04-26)
Media\Tile4.tga (196652, 2000-07-26)
Media\Tile4BumpDOT3.tga (196626, 2000-07-26)
Media\turtlebase.bmp (196664, 2001-02-16)
Media\Turtleheight.bmp (66616, 2001-02-16)
Media\White.tga (196652, 2000-07-26)
Media\WhiteBump.tga (196652, 2000-07-26)
Media\Wood.tga (197147, 2001-03-25)
Media\WoodDOT3.tga (197147, 2001-03-25)
object.cpp (3579, 2001-11-09)
object.h (1275, 2001-11-09)
ObjectManagement.cpp (22228, 2001-12-05)
Paths (0, 2001-12-06)
Paths\Combined.pth (3781, 2001-11-09)
POF (0, 2001-12-06)
POF\ball.pof (43048, 2000-06-12)
POF\bulb.pof (9668, 2000-06-01)
POF\chalice.POF (71292, 2001-07-12)
POF\crackbox.pof (75964, 2000-06-12)
POF\cylinder.pof (19644, 2001-06-27)
POF\soccerball.POF (70036, 2001-04-26)
POF\sphere.pof (43048, 2000-06-08)
POF\test.POF (1756, 2000-05-30)
POF\torus.pof (25336, 2000-06-08)
resource.h (2326, 2001-11-09)
room.cpp (9323, 2001-12-04)
room.h (1113, 2001-11-09)
ShaderDemo.cpp (21922, 2001-12-05)
... ...

//----------------------------------------------------------------------------- // Name: ShadowShader Direct3D Sample //----------------------------------------------------------------------------- Description =========== The sample RadeonShadowShader uses a stencil shadow volume technique along with mutlitexturing or pixel shaders for per pixel lighting, For each light and object, a volume representing the shadow is calculated with a vertex shader using static geometry and rendered. Since a vertex shader is doing the shadow calculations, vertex shader capable hardware can offload them from the CPU. Any pixels inside the volume are in shadow, and the result is left in the stencil buffer. For each light, if pixel shader version 1.4 or later is found, true per pixel phong shading is used to render the room including light attenuation and specular highlights. If pixel shaders are not found, a volumetric texture is used to calculate the attenuation of the light based on distance. Diffuse and specular components are calculated by dotting the tangent space normal with a light or half angle vector that is interpolated and renormalized with a cubic environment map. The final light color is then masked out by the result of the stencil shadow volume pass creating the shadows. 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 Prompts user to select a new rendering device or display mode Toggles between fullscreen and windowed modes Exits the app. Free fly mode Fly up, down, left, right. Also right drag. Fly forward, back. Also middle Drag Roll left, right. Also left Drag Pitch. Also Left Drag Toggle shadow volumes Toggle shadow volume visualization Toggle gravity Animate Lights Toggle Wireframe Mode

Toggle Physics <+> Add Ball <-> Delete Ball <*> Add Light Delete Light <0-9> Select room's lit rendering technique. Select room's ambient rendering technique. Note: 8-bit stencil must be enabled in the D3D tab of the display control panel. Programming Notes ================= Most of the pertinent code is in the root of the project. The shadow volumes are managed in ShadowPOF.cpp and rendered through shadow.sha The general idea is to create a static geometry that can be modified into a shadow volume from any light direction. To do this a geometry is created with all of the original faces and their face normals, and every edge is changed into an invisible quad connecting the two neighboring faces. The face normals are used to calculate if a face is front or back facing to the light. Back facing faces are pushed away from the light to the light's range, ripping the faces on silhouette edges apart exposing the invisible quad, which then forms the shadow volume. No shadow geometry needs to be created per frame. There are techniques that can extend this to animated geometry as well. The floor shaders contain the examples of per pixel lighting for volumetric light attenuation and diffuse and specular bump mapping. See the floor shaders. 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: Mssdk\Samples\Multimedia\Common


近期下载者

相关文件


收藏者