Chapter 23 | Materials


Material Editing and Texture Mapping

The material properties of any polygon mesh object can now be controlled through the “material” menu in left-side control panel. To illustrate how to add new materials to an object, we start with a vehicle from the Virtual CRASH vehicle database.

Next, we select the polygons whose appearance we wish to change. Note, using the elements selection type is often a faster way of simultaneously selecting multiple polygons at once. Once the polygons are selected, left-click on “new” in the materials menu.

The new material will appear in the material menu list. The material can be renamed using the name input field.

The appearance of a material will depend on the combination of the various properties seen beneath the material list in the material menu.

Diffuse color controls the color of diffuse environment light scattered in all directions off surfaces. This is the light scattered in all directions. Note, if “use parent color” is enabled, then the diffuse color for the material will be determined by the color selected in the object’s “misc” menu.

Specular color controls the color of specular environment light. This is the light reflected off surfaces in a mirror-like fashion along the axis given by a perfectly reflected ray of light.

Shininess controls the angular spread of reflected environmental light distributed about the axis given by a perfectly reflected ray of light off the surface. As this value is increased, the specular area is increased.

Shininess strength controls the overall intensity of the specular area. The larger the value, the brighter the specular area appears.

Below, the relationship between shininess and shininess strength is illustrated. 

Reflectivity controls the amount of reflection from non-light related objects in the scene (mesh objects, point clouds, images, etc). Note, the reflectivity slider becomes available only when the “reflection” toggle is enabled. This toggled is disabled by default when a new material is created.

By enabling the “transparent” toggle, one can access the opacity slider. As the opacity is reduced in value, the object will appear more transparent. In the example below, tinted windows are created by using a transparent setting of 90%.

The shadow toggle controls if a particular material is to cast a shadow in the scene. Note, currently, if the transparent toggle is enabled, the shadow option is disabled even if the shadow toggle is enabled.

Use reflection texture controls the visibility of the scrolling cloud texture map which can be observed reflecting off vehicle paint and glass. To disable the cloud texture map, simply switch the “use reflection texture” toggle off. This is often desirable for visuals created from within the occupant cabin.

Below we see the cloud texture reflecting off the vehicle’s paint.

Below we see, with “use reflection texture” disabled, the cloud texture is no longer reflecting off the paint.



Automatic Material creation by Mtl File

Polygon mesh objects, such as vehicles, can be imported into Virtual CRASH in obj, 3ds, and dxf formats. If the obj file has an associated mtl file sitting in the same file folder, the Virtual CRASH will parse the material specifications in the mtl file and automatically create materials. These materials can then be further customized in the material menu.

Here for example, we see a few entries from an mtl file used to define the materials for our vehicle model.

Here we see the materials rendered on our vehicle.

Automatic Texture Mapping by mtl File

A texture map assigns a color pattern via image file to the local 2D coordinate “(u,v)” space of the mesh object. As with mtl files described above, many 3D model builders also include texture map files along with the geometry. The mtl file tells Virtual CRASH which portions of the various image files are to be mapped onto a set of materials. Here we see an example mtl file, which references various jpg image files which contain the model’s texture mapping.

The texture map image files sit in the same file folder as the mtl. Note, it is typical to find the paths to the image files contained in the mtl file need to be modified to point to the image file location on your local hard drive. The easiest way to ensure the image files are found is to place the images, mtl, and obj file in the same file folder. Then simply remove the full path altogether as shown above.

Here we see the model imported into Virtual CRASH. Note, any logo or pattern can be added by simply modifying the image files used for texture mapping.

Manual Texture Mapping

Texture maps can be removed by either deleting the whole material using the “remove” button or by left-clicking on the “remove texture” button. As shown below, if remove texture is used, all other material properties remain in effect, but the texture map image is removed.

A texture map can be loaded manually by left-clicking on the “texture” button. In the example below, we have loaded the original texture map that came with the 3D model.

Creating your own texture map can be occasionally difficult since knowing how a texture will map to an object’s surface geometry is difficult to know. One way to better understand how an image will be mapped to a geometry is to use a pattern image file such as the one below.

Here we see the image mapped onto various shapes.

Image placement, orientation, and scale can be modified using the u scale, v scale, u offset, v offset and uv angle controls.

The “map method” option gives more control over how the texture map is to be placed on the surface geometry. By default, “object” is used, which wraps the image over the entire surface geometry using the (u,v) local space of the object. If “local xy” is selected, the image is projected downward along the object’s local z-axis (similar to the receive projection option). Note, the boarder pixels are stretched downward along the z-axis in the example below. Since the local option is used below, the mapping will not change as the objects move through the scene. If “world xy” is used, the image is projected downward along the global z-axis. In this case, the texture would be seen as static relative to the environment even as the object moves.

Logos and Decals

Suppose we wish to place a logo on our box trailer shown below; however, our truck did not come with any pre-made texture map image files we can use as a template. Here we will demonstrate two methods to place our logo.

Method 1: Logo embedded within texture map image

Switching to elements selection type, we first select the polygons of the door, then create a new material for the door.

Next, we are going to load the checkerboard texture map given above to see how an image maps to the door’s geometry. We set map method to “xz” since we want the image projected along the vehicle’s y-axis. Wet set wrap mode to “clamp” since we only want a single (non-repeating) instance of the texture map. Finally, through some trial and error, the u scale, v scale, u offset, and v offset are adjusted until the four center squares of the image are centered on the door at the desired size.

We next create a new texture map (right) with the same pixel length and width as our test image (left). We place our logo centered in the image, with the background color set to the same value as our diffuse color.

Now we simply left-click on “texture” to load our new image file. Our u scale, v scale, u offset, and v offset values were already determined in the previous step, so our logo now appears centered on the door. Note, to flip (reflect) an image about its vertical axis, set the u scale to a negative value. To flip an image about its horizontal axis, set the v scale to a negative value.

The same method can be used for any surface. Below we show the method applied for the box’s side as well as the hood.

Method 2: Layer Logo over texture map image or shader

An alternative method to apply a decal or logo, available as of the Spring 2021 Software Update, is to take advantage of the “use logo” feature. First, left-click on the material name in the material menu, next scroll down and enable the “use logo” toggle. Left-click on the “logo” button to locate the image file with your logo. Finally, set the (u,v) scale and (u,v) offset as needed.

Note, the logo feature allows users to layer a logo over another texture map. The logo image file’s alpha channel (opacity/transparency) data is used when displaying the logo.

 

Forcing Transparency using Fence

Portions of a mesh can be forced transparent by using the fence option. This option reads the alpha channel (opacity/transparency) data from the texture map file. In the example below, we see an example texture map of a leaf to be used for a hedge 3D model. The checkboard area shows the transparent pixels.

After the hedge obj file is imported into Virtual CRASH, the fence option is enabled. This ensures that the portions of the leaf polygons outside the leaf texture map remain invisible. Here we see the hedge without fence.

Here we see the hedge with the fence option enabled.



© 2024 Virtual CRASH, LLC. All Rights Reserved