Vertex Tweening

DirectX8

Vertex Tweening
 
Microsoft DirectX 8.1 (C++)

Vertex Tweening

Vertex tweening is used to blend two user-provided positions or normal streams. It can be used only with declarations. Tweening is enabled by setting D3DRS_VERTEXBLEND to D3DVBF_TWEENING. Vertex blending using weights and vertex blending tweening are mutually exclusive.

The C++ DolphinVS Sample uses vertex tweening to animate a dolphin so that it appears to move through the water. The images below show the dolphin at two different points. Notice that the dolphin's tail has gone from an up position to a down position and its nose points downward more in the right image.

Tweening is performed before lighting and clipping. The resulting vertex position (normal) is computed as follows:

POSITION = POSITION1 * (1.0 - TWEENFACTOR) + POSITION2 * TWEENFACTOR, and likewise for normals.

Additional information is contained in the following topic.

Vertex Shader Tweening

The code for using vertex shader tweening is similar to the code for the fixed-function tweening shown in the Using Vertex Tweening topic. The only difference is the call to IDirect3DDevice8::CreateVertexShader as shown below.

m_d3dDevice->CreateVertexShader( decl, &vsFunction, &handle, 0 );

The second parameter for CreateVertexShader takes a pointer to a vertex shader function token array. This function can be created by calling any of the following functions.