Working With Materials

Introduction

In this exercise you'll learn work with material palettes.

Material & Texture Nodes

A material node is a node that you can apply to the faces of a mesh. A texture node simply points at a raster file such as BMP or PNG on the hard disk and cannot be applied directly to either a mesh or face set in the mesh. A material node references a texture node via a parameter in the material node property sheet.

About Mesh Palettes

A mesh palette is just to which a mesh node is linked. This uses the group like a bucket in which a set of materials are stored. This is pretty basic; you can store actual materials in the group or you can store links to materials in another file. Best practice is using mesh palettes that contain links to materials in a global palette. If you apply a common material to mesh geometry you should probably use a link node to reference the material in a global palette BOX file.

Global Palettes

Global palettes are necessary because centralized data storage is one of the fundamental principles to successful database design. Therefore it is a good idea to create a series of material palette files in which common material nodes are stored along side common texture nodes. These material and texture palettes do not store any scene geometry; only materials and textures. This is very similar to the principle in object oriented programming that uses one definition called a class to define an object that will be used many times. To change the object definition you change one file instead of many. Functions are similar. Instead of writing a block of code and using copy/paste to implement the same functionality, you define the block as a function and call the function from other locations. Using numerous local materials instead of common materials means that portions your scene content are stored in numerous locations. If you wish to change this content, you have to find it everywhere it is used and make the changes. Using global palettes means making one change that instantly affects the entire database.

Example Terminology

The term "points at" means the node stores a pointer to another node or that the node has a property that stores a pointer to another node. The term "referenced by" means that another node stores a pointer to the node in question. Typically this "point at" parameter is implemented by the scene builder who performs an action such as assigning a specific texture to a material. After assigning a texture to a material, the material "points at" the texture and the texture is "referenced by" the material.

The Resource Model On Disk

Figure 1.1. Texture files on the hard disk. These texture files are stored as resources on the hard disk.

The Directed Acyclic Graph

This is the most common directed acyclic graph structure for a material and texture palette.

Figure 1.2. Nodes in the scene graph. The texture nodes are linked to texture files on the hard disk by the Texture File parameter of the texture node. The material nodes are linked to the texture nodes by the Texture parameter of the material node. Here the dependency graph is more or less invisible unless the node parameters are examined.

Figure 1.3. Nodes in the scene graph. The texture nodes are linked to texture files on the hard disk by the Texture File parameter of the texture node. The material nodes are linked to the texture nodes by the link nodes. These link nodes point at the texture nodes and the texture nodes point at the files on the hard disk. The dependency graph is easily visible in this example.

Figure 1.4. Visualize The Dependency Graph. For the purpose of visualization only, this presentation of the dependency graph makes it easier to understand how the dependency graph of the global material palette is traversed. This highlights a very important feature of a correct dependency graph - acyclicality. This dependency graph terminates predictably just like the directed acyclic graph. With the exception of the link node, Scenome's nodes do not allow the modeler to create circular dependencies. However the link node has no such restriction and can be used to implement non-terminating dependency graphs. That topic is discussed in greater detail in this document. NOTE: A dependency graph is different from a dependency and reference graph, where circularity is commonplace and expected.

    • SandMaterial
    •       
    •       
    • SandTexture
    •       
    • ..\textures\sand_texture.bmp
    • GrassMaterial
    •       
    •       
    • GrassTexture
    •       
    • ..\textures\grass_texture.bmp
    • WaterMaterial
    •       
    •       
    • WaterTexture
    •       
    • ..\textures\water_texture.bmp
    • RoadMaterial
    •       
    •       
    • RoadTexture
    •       
    • ..\textures\road_texture.bmp
    • SkyMaterial
    •       
    •       
    • SkyTexture
    •       
    • ..\textures\sky_texture.bmp

Conclusion

There are many ways to create global palettes inside BOX files. The method you choose depends largely on two factors: 1.] the requirements of your application and 2.] your comfort level with respect to indirection. Using link nodes makes it possible to integrate the scene's dependency graph into the scene graph in such a way that it can be manipulated and traversed by the scene builder. It also makes it possible to automate a variety of otherwise tiresome operations.

Finished Version

There is no finished version of this model available.