d3d_grass
所属分类:DirextX编程
开发工具:Visual C++
文件大小:458KB
下载次数:123
上传日期:2006-11-28 03:17:41
上 传 者:
laowei
说明: 利用DirectX绘制三维草的代码,对于装饰大规模的室外场景,有参考价值.
(use DirectX 3D Drafting code for the large-scale decorative outdoor scenes, a reference value.)
文件列表:
grass (0, 2004-04-27)
grass\resource.h (1380, 2001-09-21)
grass\media (0, 2002-07-25)
grass\media\GRASS_GROUND.tga (196652, 2002-07-25)
grass\media\thingrass0000.tga (241969, 2001-10-01)
grass\shaders (0, 2002-07-25)
grass\shaders\grass.psh (131, 2002-07-25)
grass\shaders\grass.vsh (2343, 2002-07-30)
grass\directx.ico (1078, 2001-07-13)
grass\Grass.cpp (18006, 2002-07-26)
grass\Grass.dsp (5210, 2002-07-26)
grass\Grass.dsw (614, 2002-07-24)
grass\Grass.exe (352256, 2002-07-26)
grass\framework (0, 2002-07-26)
grass\framework\d3dapp.cpp (75328, 2001-10-31)
grass\framework\d3dfile.cpp (24189, 2001-10-31)
grass\framework\d3dfont.cpp (23795, 2001-10-31)
grass\framework\d3dutil.cpp (23266, 2001-10-31)
grass\framework\dxutil.cpp (23668, 2001-10-31)
grass\framework\d3dapp.h (9179, 2001-10-31)
grass\framework\d3dfile.h (4344, 2001-10-31)
grass\framework\d3dfont.h (2487, 2001-10-31)
grass\framework\d3dres.h (1664, 2001-08-17)
grass\framework\d3dutil.h (10718, 2001-10-31)
grass\framework\dxutil.h (5147, 2001-10-31)
grass\winmain.rc (5124, 2001-09-21)
//-----------------------------------------------------------------------------
// Name: Grass Sample
//
// Copyright (c) 2002 ATI Technologies Inc. All rights reserved.
//-----------------------------------------------------------------------------
Description
===========
The Grass sample demonstrates the use of vertex and pixel shaders to
create the effect of a grass waving in the wind.
The availability of programmable vertex and pixel shaders has allowed
programmers to re-examine how they implement passive background scene
geometry. With the ability to transfer background scene animation
over to the GPU, previously static background objects can now be
animated, adding life and realism to the scene. In this sample, an
approach is shown for realistically and inexpensively animating grass
with a combination of vertex and pixel shaders.
Path
====
Source: samples\Grass
User's Guide
============
The following keys are implemented. The dropdown menus can be used
for some of the same controls.
Toggles the vertex shader
Toggles the pixel shader
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.
Programming Notes
=================
The waving motion of the grass can be accomplished in the vertex
shader. Using a traditional method the grass is rendered with
randomly placed intersecting quads stored in a single vertex buffer.
The quads are texture mapped and rendered with an alpha test. In the
vertex shader, the top two vertices of each quad are animated using a
combination of four sinusoidal waves. The waves are approximated
using a Taylor Series approach. This combination of sine waves using
various different frequencies creates a natural waving that does not
look like an animation or overly repetitious.
When grass blades wave in the wind they also turn and change their
orientation with respect to the sunlight. Because this method
involves using a textured quad to represent various blades of grass it
is impossible to change the lighting on individual grass blades. To
simulate the change in color that would occur as the blades twist the
wind, the same sine wave that was used to animate the grass is used to
oscillate between two colors. In this case, the green channel of the
color was changed to make the grass color change from intense green to
a more yellowish-brown. The pixel shader combines this color with the
grass texture to produce the final result.
近期下载者:
相关文件:
收藏者: