qcycp

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Cg - The Cg Tutorial Ch6. Animation 筆記

1.  You could compute animation updates on the CPU and pass the animated data to the GPU.
     However, a more efficient approach is to perform as much of the animation computation as possible
     on the GPU with a vertex program, rather than require the CPU to do all the number-crunching.
     Offloading animation work from the CPU can help balance the CPU and GPU resources and free up the
     CPU for more involved computations, such as collision detection, artificial intelligence, and game play.

 

2.  The sin function is just as efficient as addition or multiplication in the CineFX architecture.
     In fact, the cos function, which calculates the cosine function, is equally fast.

 

3.  If a computed value is a constant value for an entire object, optimize your program by precomputing
     that value on a per-object basis with the CPU. Then pass the precomputed value to your Cg program
     as a uniform parameter. This approach is more efficient than recomputing the value for every fragment
     or vertex processed.

 

4.  Vectorize your calculations whenever possible, to take full advantage of the GPU's powerful vector-processing capabilities.

 

5.  When you render a point to the screen, an output parameter with this semantic specifies the width
     (and height) of the point in pixels. This gives your vertex program programmatic control of the point size used by the rasterizer.

 

6.  You can improve the particle appearance by using point sprites. With point sprites, the hardware takes each
     rendered point and, instead of drawing it as a single vertex, draws it as a square made up of four vertices.
     Point sprites are automatically assigned texture coordinates for each corner vertex. This allows you to alter
     the appearance of the particles from a square to any texture image you want.

 

7.  When an application uses a Cg vertex program to perform the key-frame blending operations, the CPU
     can spend time improving the gameplay rather than continuously blending key frames. By using a Cg
     vertex program, the GPU takes over the task of key-frame blending.

 

8.  Another approach to animating characters is vertex skinning. Many 3D modeling packages author 3D
     content suitable for vertex skinning. The technique is also known as matrix palette blending.
     vertex skinning maintains a single default pose and a large set of matrices that appropriately rotate and
     translate various subregions of the default pose's polygonal mesh. For reasons that will become apparent,
     these various matrix transforms are often called "bones."
     For correct lighting, you can compute the same sort of transformed and weighted average used for positions,
     except that you transform normals by the inverse transpose of each matrix rather than by the matrix itself.
     Weighted normals may no longer be unit length, so normalization is required.

 

9.  With vertex skinning, each pose requires just the default pose—shared by all poses—and the matrix
     values for the given pose. There are generally substantially fewer matrices per character than vertices,
     so representing a pose as a set of bone matrices is more compact than representing the pose with a key frame.

 

posted on 2009-02-12 17:36  qcycp  阅读(117)  评论(0)    收藏  举报