grass
所属分类:Windows编程
开发工具:Visual C++
文件大小:512KB
下载次数:297
上传日期:2006-07-28 14:10:36
上 传 者:
whf813
说明: 模仿大自然草的运动。用DX9编写,用泰勒公式逼近
(mimic natural grass movement. With DX9 prepared with Taylor approximation formula)
文件列表:
directx.ico (1078, 2001-07-13)
framework (0, 2002-07-26)
framework\d3dapp.cpp (75328, 2001-10-31)
framework\d3dapp.h (9179, 2001-10-31)
framework\d3dfile.cpp (24189, 2001-10-31)
framework\d3dfile.h (4344, 2001-10-31)
framework\d3dfont.cpp (23795, 2001-10-31)
framework\d3dfont.h (2487, 2001-10-31)
framework\d3dres.h (1664, 2001-08-17)
framework\d3dutil.cpp (23266, 2001-10-31)
framework\d3dutil.h (10718, 2001-10-31)
framework\dxutil.cpp (23668, 2001-10-31)
framework\dxutil.h (5147, 2001-10-31)
Grass.cpp (18006, 2002-07-26)
Grass.dsp (5210, 2002-07-26)
Grass.dsw (614, 2002-07-24)
Grass.exe (352256, 2002-07-26)
media (0, 2002-07-25)
media\GRASS_GROUND.tga (196652, 2002-07-25)
media\thingrass0000.tga (241969, 2001-10-01)
resource.h (1380, 2001-09-21)
shaders (0, 2002-07-25)
shaders\grass.psh (131, 2002-07-25)
shaders\grass.vsh (2343, 2002-07-30)
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.
近期下载者:
相关文件:
收藏者: