The HOOPS 3D Framework Material Library offers a repository of specially designed material resources to enhance the rendering of your scene. You can obtain the repository by downloading the Material Resources package from the Developer Zone. The materials in this repository were developed by a team of highly skilled artists, pixel shader experts and engineering and visualization industry veterans. Together, they created a collection of the most commonly found materials in the engineering and visualization space. Each material consists of photorealistic textures that have been paired with highly tuned custom shader code that accentuates the uniqueness of each material. These materials can be loaded into the HOOPS 3DF via the HMaterialLibrary class found in HOOPS/MVO. To learn more about how to use the HMaterialLibrary, please read on our overview of the Material Library.
The following tables shows a preview of the some of the materials offered in this library:
![]() Car Interior Plush |
![]() Car Seat |
![]() Car Seat Diamonds |
![]() Leather |
![]() Brass |
![]() Brushed Metal |
![]() Brushed Metal Discs |
![]() Cast Aluminum |
![]() Chrome |
![]() Copper |
![]() Painted Cast Metal |
![]() Plain Metal |
![]() Car Paint |
![]() Rough Plaster |
![]() Smooth Plaster |
![]() Metallic Paint |
![]() Green Granite |
![]() Salmon Granite |
![]() Orange Granite |
![]() Spectrolite Granite |
![]() Walnut Car Panel |
![]() Pine |
![]() Bamboo Floor |
![]() Oak Floor |
![]() Oak |
![]() Concrete |
![]() Glass |
The materials in the HOOPS 3DF Material Library can easily be used and accessed without a detailed understanding of the material specifications. However, it might be useful to understand the format of the materials specification if you want to make any modifications, additions or customizations to the materials in this library.
As defined in the Material Library, a material is a collection of textures and a custom shader that determines the composition of each texture layer. In each directory, it looks for a metafile called "index.dat". This file specifies the definition of a single material. There can be only one material defined per directory. During the materials registration process, the Material Library will use the name of the directory as the registered name of the material defined in it. Note that directory names may have wide characters but the contents of the directories and files must be ASCII.
The index.dat metafile is a specially formatted plain text file that specifies a material's composition. When HMaterialLibrary reads an index.dat file, it expects a list of records. A record describes an element of the material. The following are possible elements that can be described:
A record describes an element via a series of single entry lines. Each line has a name/setting pair where the name is separated from the setting information by a colon. The first entry of a record identifies the element being defined. The name should be CHANNEL and the setting can be either SHADER, TEXTURE or ENVIRONMENT. For example, a shader record might look like the following:
CHANNEL: SHADER SOURCE: car_panel_walnut.hlsl
Note that strings are not quoted.
Shader
For each material, you can define one custom shader. Your shader code can be written in glsl or hlsl. When you specify a shader record, you can use the following to describe your shader:
Let's take a look at an example of a shader record:
CHANNEL: SHADER SOURCE: copper.hlsl MULTITEXTURE: off PARAMETERIZATION_SOURCE: uv TWEAKABLES: base_color
In the sample above, we define a custom shader whose source is found in the copper.hlsl file. The record indicates that multitexture is disabled and the parameterization is "uv". Finally, the variable whose default value we can change dynamically is named "base_color".
Texture
For each material, you can define up to seven textures. Each texture record must to have a CHANNEL and a SOURCE entry:
Let's take a look at an example of two texture records:
CHANNEL: TEXTURE1 SOURCE: floorboards_bamboo_diffuse_2k.tga CHANNEL: TEXTURE2 SOURCE floorboards_bamboo_disp_2k.tga
In the sample above, we define two textures. TEXTURE1 specifies a source that is a diffuse bamboo floorboard image while TEXTURE2 uses as its source a different bamboo floorboard image.
Environment
For each material, you can define one environment. Each environment record needs to have a CHANNEL and a SOURCE entry:
Let's take a look at an example of an environment record:
CHANNEL: ENVIRONMENT SOURCE: environment2
In the sample above, we define a environment for our material. The source indicates environment2. This means at render time, our material will use the second cube map of the current environment.
The tweakables entry gives you the ability to allow the user to change default values of specific variables in the shader code once it has been loaded. You can specify these variable in a shader record by adding a TWEAKABLES entry in your shader record. Let's take a look at the sample index.dat file below:
CHANNEL: SHADER SOURCE: tweakable.hlsl MULTITEXTURE: off PARAMETERIZATION_SOURCE: uv TWEAKABLES: my_tweak
The shader record above identifies the variable my_tweak as tweakable. This means that when HOOPS 3DF loads the tweakable.hlsl file, it will look for a variable whose declaration looks like one of the following:
float my_tweak = #;
float2 my_tweak = float2(#, #);
float3 my_tweak = float3(#, #, #);
float4 my_tweak = float4(#, #, #, #);
The '#' represents a single floating point number. We require this particular format because it works in both in hlsl and glsl. Note, that the declaration (e.g. "float my_tweak") and initialization (e.g. "my_tweak = #") must occur within the same source line.
In our shader code below, we implement the tweak_color function to customize the color shader. The tweak color function uses the my_tweak variable to determine the color:
void tweak_color(const HGlobals globals, inout HColor color) { float3 my_tweak = float3(0.1, 0.3, 0.24); color.diffuse.rgb = my_tweak; } #define H3D_COLOR_SHADER tweak_color
Within the Material Library, you can specify environments. Environments are defined on a per directory basis like materials. The metafile that describes an environment is called "environment_index.dat" as opposed to "index.dat" for materials.
The environment_index.dat metafile is a specially formatted plain text file that specifies an environment's composition. When HMaterialLibrary reads an environment_index.dat file, it expects a list of records. A record describes an element of the environment. The following are possible elements that can be described:
A record describes an element via a series of single entry lines. Each line has a name/setting pair where the name is separated from the setting information by a colon. The first entry of a record identifies the element being defined. The name should be CHANNEL and the setting can be either LIGHT or CUBEMAP appended by a number from 0 to 7. For example, a cube map record might look like the following:
CHANNEL: CUBEMAP0 SOURCE: chrome
Note that strings are not quoted.
Cube Maps
For each material, you can define up to eight cube maps. In a cube map record, you can have the following settings:
Let's take a look at an example of two cube map records:
CHANNEL: CUBEMAP0 SOURCE: chrome CHANNEL: CUBEMAP1 SOURCE: diffuse
In the sample above, we define two cube maps. CUBEMAP0 specifies that there is a set of 6 source images whose names begins with chrome (chrome_negx.jpg, chrome_negy.jpg, chrome_negz.jpg, chrome_posx.jpg, chrome_posy.jpg, chrome_posz.jpg), while CUBEMAP2 uses as its source a set of image files whose names begin with diffuse.
When HMaterialLibrary loads in the environment specified by those two records, it creates an environment with multiple cube maps associated with it. When HMaterialLibrary reads the CUBEMAP0 record, it creates a texture called "environment0" composed of images whose names begin with chrome. Within the HOOPS 3DF database, when a cube map is loaded as a texture, it is named "environment<d>" where the <d> is the number appended to CUBEMAP. Thus the record CUBEMAP1 results in a texture named "environment1" composed of images whose names begin with diffuse.
Lights
For each material, you can define up to eights lights. In a light record, you can have the following settings
Let's take a look at an example of a light record:
CHANNEL: LIGHT4 OPTIONS: -1.0 0.2 -1.0 COLOR: lights=(R=1.0 G=0.9 B=0.75), ambient up=(R=0.46 G=0.55 B=0.73), ambient down=(R=0.36 G=0.36 B=0.44)
In the sample above, we define a light whose direction is given by the three floats in the options entry. In the color section, we define the color not only for the light but also hemispheric ambient color values.