DirectX SDK

Untransformed and Lit Vertices

If you include the D3DFVF_XYZ flag, but not the D3DFVF_NORMAL flag, in the vertex format description you use with the Direct3D rendering methods, you are identifying your vertices as untransformed, but already lit. (For information about other dependencies and exclusions, see Flexible Vertex Format Flags.)

By using untransformed and lit vertices, your application requests that Direct3D not perform any lighting calculations on your vertices, but it should still transform them using the previously set world, view, and projection matrices. Because the system isn't doing lighting calculations, it doesn't need a vertex normal. The system uses the diffuse and specular components at each vertex for shading. These colors might be arbitrary, or they might be computed using your own lighting formulas. If you don't include a diffuse or specular component, the system uses the default colors. The default value for both the diffuse and specular colors is 0xFFFFFFFF.

Like the other vertex types, other than including a position and some amount of color information, you are free to include or disregard the texture coordinate sets in the unlit vertex format.

[C++]

C++ applications can still use the legacy D3DLVERTEX structure for vertices. The d3dtypes.h header file defines the following helper macro that you can use to describe the D3DLVERTEX structure's format:

#define D3DFVF_LVERTEX ( D3DFVF_XYZ | D3DFVF_RESERVED1 | D3DFVF_DIFFUSE | \
 D3DFVF_SPECULAR | D3DFVF_TEX1 )

Note that the helper macro includes the D3DFVF_RESERVED1 flag, indicating to the system that you're using the D3DLVERTEX structure, which includes the dwReserved member. This is required when using D3DLVERTEX because vertex formats don't usually include reserved fields; the D3DFVF_RESERVED1 flag informs the system that there is an unused DWORD between the vertex's position and diffuse color vertex components.

If the D3DLVERTEX structure doesn't include all the fields your application needs, you can define another structure. Make sure that your vertex components appear in the required order, declaring a new structure accordingly. The following code declares a valid untransformed and lit vertex, with diffuse and specular vertex colors, and three sets of texture coordinates:

//
// The vertex format description for this vertex 
// would be: (D3DFVF_XYZ | D3DFVF_DIFFUSE | 
//    D3DFVF_SPECULAR | D3DFVF_TEX3)
//
typedef struct _LITVERTEX {
    float x, y, z;// position
    
    DWORD dwDiffuseRGBA;  // diffuse color
    
    DWORD dwSpecularRGBA; // specular color
    
    float tu1,    // texture coordinates
  tv1;
    
    float tu2,
  tv2;
    
    float tu3,
  tv3;
} LITVERTEX, *LPLITVERTEX; 

The vertex description for the preceding structure would be a combination of the D3DFVF_XYZ, D3DFVF_DIFFUSE, D3DFVF_SPECULAR, and D3DFVF_TEX3 flexible vertex format flags. The rendering methods, such as IDirect3DDevice7::DrawPrimitive, accept the address of a vertex array as a void pointer, so remember to cast your vertex array pointer to the LPVOID data type when you call the rendering methods.

For more information, see About Vertex Formats.

[Visual Basic]

Applications written in Visual Basic can define their own vertex formats, or use the D3DLVERTEX type for lit vertices. If the D3DLVERTEX type doesn't include all the fields your application needs, you can define another type. Make sure that your vertex components appear in the required order, declaring a new type accordingly. The following code declares a valid untransformed and lit vertex, with diffuse and specular vertex colors, and three sets of texture coordinates:

'
' The vertex format description for this vertex
' would be: (D3DFVF_XYZ Or D3DFVF_DIFFUSE Or
'    D3DFVF_SPECULAR Or D3DFVF_TEX3)
'
Type LITVERTEX
    x As Single ' position
    y As Single
    z As Single
    
    DiffuseRGBA As Long ' diffuse color
    
    SpecularRGBA As Long ' specular color
    
    tu1 As Single ' texture coordinates
    tv1 As Single
    
    tu2 As Single
    tv2 As Single
    
    tu3 As Single
    tv3 As Single
End Type

The vertex description for the preceding type would be a combination of the D3DFVF_XYZ, D3DFVF_DIFFUSE, D3DFVF_SPECULAR, and D3DFVF_TEX3 flexible vertex format flags. The rendering methods, such as Direct3DDevice7.DrawPrimitive, accept the first element of a vertex array as type Any, to accommodate all types of vertex formats.

For more information, see About Vertex Formats.