Models and Shaders

Many authoring tools assign surface properties to models, including, transparency, bumpiness, or a diffuse color bitmap. These surface properties are called shaders, textures, or materials depending on the tool. To avoid confusion, because all these terms are used in Shockwave 3D§, note the following definitions:

Shader: The attributes of a surface at the highest level.

Material: The attributes of a surface at the lowest level, including diffuse color, opacity, and specular color.

Texture: An image or bitmap that is applied to an object's diffuse, specular, bump, or reflection channels.

Style: A collection of shaders, also referred to as a "shader group," used by an IFXModelResource and stored in the IFXModelData object attached to the IFXModelResource.

IFXAuthorMesh and Shaders

When setting up the faces in an IFXAuthorMesh, each face must have the index of the appropriate entry in a style that describes the face's surface properties. IFXMeshGroup, which contains the render-time optimized version of the IFXAuthorMeshGroup, breaks each IFXAuthorMeshGroup into submeshes using these shader indices, one per shader applied to the AuthorMesh.

Neither the IFXMesh class nor the IFXMeshGroup class records the shader that is used on a given IFXMesh. As a result, the following must be done when building the IFXAuthorMeshGroup.

With this list, you can build the IFXAuthorMeshGroup. When populating the IFXAuthorFace structures in the IFXAuthorMesh, set the ShaderId() field to the index in the list of shaders corresponding to the shader used by the face. The result will be the following indirection: the face will contain a list index. Each entry in the list contains an index in the Shader Resource Palette. Each entry in the Shader Resource Palette points to the Shader Resource, which actually describes the properties of the surface at that face.

After the IFXMeshGroup is created (broken up by the index values that you put in the ShaderID fields), the values in this list should go directly into the IFXStyle (style or shader group) that you create for this model and place in its Style Palette, which resides in the IFXModelData object in the IFXModelResource.

Keep resource sharing in mind. If two clones of a model use the same style (the same set of shaders in the same order), don't add the duplicate styles to the Style Palette of their shared IFXModelResource. Make sure that the entry for each copy of the model in the Node Hierarchy Palette references the same style index in the Style Palette. If all copies of a model do not use the same set of shaders in the same order (remember that order is important, because all copies of the model share a common mesh that was split up by shader index), you need to create one entry in the IFXModelResource's Style Palette for each unique combination of shaders (each unique style).

§See asterisked (*) statement at Legal Information © 2001 Intel Corporation.