Tutorials

By Jeff Mottle

Mostly Materials

Editor's notes

Article brought to you by Ted Boardman
Jeff Mottle — Founder at CGarchitect

Mostly Materials

Ted Boardman tedb@tbmax.com         http://www.tbmax.com


It has seemed like an awfully cold spring here in New England. I don’t keep tabs on the actual temperature but gauge things from the amount of time I can spend on my front porch and sitting out at my favorite café for morning coffee. So far it’s been pretty dismal, only two or three mornings has it been warm enough at 6:30am when I go to coffee and that’s wearing a flannel shirt. The porch has been a little better in the afternoon as long as the wind isn’t up off the water, but at 58 degrees Fahrenheit water temperature even the slightest breeze sends me into the house. Of course, that’s exactly what will make the summer heat tolerable if it ever does arrive, so I’ve got to be careful how much I complain.

This might be a tough year for boating along the New Hampshire and Maine coast when the hot weather does cover the area because the combination of hot air and cold water produces some of the thickest fog you can imagine in July. By August the water will warm to 65 degrees or so and the chances of extremely thick fog lasting all day is much less likely. The rocky inlets and islands combined with fast tide flows of the Maine coast make it especially challenging to those not prepared for navigating in those conditions. The new GPS navigation units are certainly helpful, but there is no substitute for traditional skills of chart reading and buoy identification combined with dead reckoning navigation and common sense. I’ll watch it all from my porch if I can see that far.

Speaking of breezes…a process that seems like it should be a breeze is often the one that you spend the most time on. For example, I got an email this morning from someone trying to snap a line to a vertex at the bottom corner of a upper story window opening and then just creating the line straight out from the window. Naturally, the next pick places the vertex on the current World Grid dropping the endpoint of the line to the “ground”. I’ll show you how to keep subsequent vertices at the same elevation as the first pick.

Also this month I’m going to work a little with materials to show a method of applying road stripes to lofted roads. The reason I’m using the lofted road is to illustrate the extremely flexible workflow that is possible when working in VIZ or max with parametric objects and parametric maps in materials. Taking advantage of these parametric features helps turn VIZ and max from a very capable visualization tool to a powerful design and visualization tool, the emphasis on design where sweeping changes must be made without reinventing the wheel each time you want to implement simple changes to the model or materials.

AutoGrid for Lines in Space

For those who use the AutoGrid feature in VIZ or max it is viewed, rightly so, as a method of creating objects on the surface of other objects in planes defined by the Face Normal. It functions by reading the Local Reference Coordinate System of the sub-object item currently below the cursor and creating a temporary Grid for the creation process. In the case of snapping to Mesh vertices you can take advantage of a little known fact to force the line in the plane you want it to go.

First it is important to note that when you use Snaps in VIZ or max the snap point is chosen based on it proximity to the nearest feature in pixels. For example, if you snap to a vertex, the nearest vertex within 8 pixels (the default in Customize, Grid and Snap Settings, Options, Snap Strength) is selected. You can use this to snap to a vertex, then move the cursor 4 pixels away from the vertex to read the Face Normal below the cursor to determine the plane for a temporary AutoGrid. If 3 faces share a vertex you can move the cursor around to define 3 different AutoGrid planes. This assumes that the AutoGrid is set in User Grids tab to use Object Space. The plane can be forced into World Space by changing the option. By zooming in on the vertex or by changing the number of pixels in the Strength setting you can adjust your accuracy and flexibility.

Figure 1 shows a VIZ 4 scene in which AutoGrid is enabled in the bottom Status bar, the Snap is set to vertex, and the Line command is activated. The axis tripod shows the XY plane that will be used for the new AutoGrid as defined by the vertical faces inside the opening.

Figure 1: The Line command is activated and the AutoGrid is on. The AutoGrid plane will be determined by the XY axis of the Local Reference Coordinate System of the face under the cursor.

Note: In versions of max, the AutoGrid can be activated with the checkbox in the Modify panel after you click the Line command button. Otherwise the process is the same.

The steps you use for creating lines in a certain plane based on a Snap setting are:

Set Snap type, for example Vertex, and turn Snap on. Click the Line button and active AutoGrid Position the cursor over a vertex. The small cyan colored tick will appear when you are snapping to the vertex. Move the cursor slightly off the vertex, the cyan tick should remain, and move the cursor over the plane you want to define the new temporary Grid. You will see the axis tripod flip as it reads the Face Normals under the cursor. Click the start the line on the vertex, and then click in space to place the next vertex in the new active grid plane.

Snap is still active so you must not snap on a new vertex that will force the line out of the grid plane. To deactivate the Snap for a single pick, hold the Shift key and right-click with the mouse. Choose None to keep the next pick from snapping to another vertex. See Figure 2.

Figure 2: To avoid inadvertently snapping to another vertex after entering AutoGrid mode, hold Shift and right-click to choose None from the menu. This will override snaps for the next pick. You must do it separately for each new override.

Practice a bit with this line creation method and it will become a tool available to improve your workflow when needed.

Yipes Stripes!

The exercise here is to show a workflow and thought process as much as to create a material, but the resulting material might be useful to you in spite of that. The material is a road material that can be easily edited for different surfaces and line configurations. It will illustrate one approach for constructing such a material, but there are several combinations of material and map types that could provide different levels of control and flexibility. I encourage you to follow the logic here, then apply that thought process to come up with you own variations that will fit your needs. Also, don’t become fixated on this process as a method of creating only roads with stripes, but stretch your imagination to find other applications.

The Model

The first important aspect of the exercise is that the road (RoadStripe.max is a VIZ 4 file, see Figure 3) is a lofted object. A rectangle has been lofted along a curved line which is the only method of modeling I know of that will generate it’s own mapping coordinates. This adds flexibility so that when you adjust the curvature of the road the maps will adjust themselves accordingly, always remaining in place.

Figure 3: The road model is a simple rectangle lofted along a curved line for this exercise.

The Material

To get the base material created I will start with a Standard material type and use procedural maps to generate the surface. I’ll keep it relatively simple so it will be easy to follow the concepts without bogging down in details of specular highlights and bumps, etc. that will make a first class material.

For the base asphalt look I’ll apply a Noise map in the Diffuse slot and make it white specks on dark grey with a size of 1.0 and High and Low Threshold of 0.65 and 0.60. To apply white stripes to the asphalt I’ll click on the Noise map in the Material and choose Composite map from the list. I’ll Keep the Old Map as a Sub Map. A Composite map allows you to layer maps on each other using black in the map as transparency or with Alpha channel if the map contains it. Figure 4 shows the Material/Map Navigator so far.

Figure 4: A Composite material can layer 2 or more materials to reveal the lower layers with transparency, either black in the map or Alpha channel.

I’ll click the Map 2: None slot of the Composite material and choose Gradient Ramp map for the stripe. First, I’ll lower the Blur of the Gradient Ramp for crisper edges. Then set the colors to black and white with Interpolation set to Solid and adjust the flags as in Figure 5. In the Output rollout, check the Alpha from RGB Intensity to use black as transparent and white as opaque because the Gradient Ramp map doesn’t have an Alpha channel

Figure 5: Gradient Ramp set to create a crisp stripe composited down the center of the asphalt map.

Perhaps the road should have a double line. I’ll add a new slot to the Composite map with the Set Number button and then drag and drop a Copy clone of the Gradient Ramp into the new Composite slot. This creates two stripes but they are directly on top of each other. This can be fixed by moving the flags of one Gradient Ramp a bit to the left and the other a bit to the right. You will have to render the scene to see both maps because Show Map in Viewport only shows the current map. It would be nice if I could indicate a dashed passing line, huh. That’s not a problem and can be accomplished using another Gradient Ramp as a Mask map which will reveal only part of the stripe it is applied to based on the black and white areas of the new Gradient Ramp. In either existing Gradient Ramp level, I will click the Gradient Ramp button and choose Mask from the list of maps. Keep the Old Map as a Sub map. Drag and drop the Gradient Ramp map onto the Mask None button and make it a Copy clone. In the new Gradient Ramp map in the Mask slot, drag a flag off the right edge and move the remaining flag to make a equal black and white ramp. Enter 90 in the W Angle field to rotate the map and enter 10 in the U Tiling field to cause the map to repeat 10 times over the length of the road for a dashed line. See Figure 6.

Figure 6: A Mask map added to one of the stripes with a new Gradient Ramp as the mask can be used to create a dashed passing line.

As mentioned, this is one simple method of creating a flexible set of road stripes. Other, more complex and flexible, options could be created with Blend and Composite material combinations. Here I have used the power of the built in map types to full advantage and am not as restricted as I would be if using bitmaps.

To follow up on my initial statement that the use of lofted objects adds greatly to the flexibility I will move a vertex of the loft path and adjust it’s Bezier handles to radically change the curve of the road. The map adapts itself perfectly to the new curvature with no adjustments necessary to keep the stripes intact. See Figure 7.

Figure 7: By modifying the center vertex of the loft path I was able to adjust the curvature of the roadway and still have the material keep its correct orientation and layout. This is one of the biggest advantages of lofted objects.

Summary

Lines in space and stripes on curved roads don’t have much in common, but each illustrates uses of the powerful options available in max and VIZ that are not always apparent on the surface.

Learn the relatively simple concepts and workflow in the software and use combinations to create complexity that can be easily edited at any time.

Good luck and have fun.

Ted

DOWNLOAD MAX FILE

You must be logged in to post a comment. Login here.

About this article

Mostly Materials

visibility2.36 k
favorite_border0
mode_comment0
Report Abuse

About the author

Jeff Mottle

Founder at CGarchitect

placeCalgary, CA