Texture Mapping

Attaching painted, scanned, etc. images to objects is one of the most commonly used techniques in texturing. This chapter examines the basic tools and controls for texture mapping.

Level: Beginner/Medium

Example file: 'tutorprojects\material\mapping\can'

In this tutorial we will create a soft drink can with some labels painted on it. For the sake of simplicity, the shape of the can may be just a simple cylinder.

1. Activate a top view and switch to the Analytic tab of the toolbar. Select Cylinder from the tool's menu. Then create the cylinder with two mouse clicks on the view window.

Modeling a can using the Analytic cylinder tool

2. Activate a front view and stretch the length of the cylinder until the shape is suitable for a soft drink can. To do this you can use:

  • the scale handle at the end of the cylinder's handle axis

  • the numerical axis control in the property window's Spec tab

  • or the extend or scale tools

3. Go to the Materials tab of the Select window. Choose New/From Template from the popup menu. Using the file browser, select the template Image Maps/Color Map. Click Open.

The color texture map material

4. Double click the icon of new Color Map material to open the property window. Using the browse button at the right side of the File Name gadget, select the sample texture 'lake' from the textures sub-folder of the Realsoft 3D installation directory. You can also use any other image if you like.

Cylinder mapping

5. Close the property window. The cylinder should be selected at this point; if not, click its wireframe to select it. Then drag & drop the Color map material from the select window to the view window.

6. This drag & drop action automatically creates a cylinder mapping that matches the can. This happens because the Color Map template is defined to behave this way (find out more about preferred mappings from the VSL tutorials). The cylinder mapping wraps the selected image nicely around the can and is a good starting point for further editing.

7. Slightly rotate the view downward from the front view and render it.

As you see in the image, there are some problems. The bottom of the shows strange artifacts

8. The artifacts at the bottom indicate accuracy problems. The cylinder map and the can have exactly the same length. It is impossible to say which one ends first, the texture mapping or the can (computers have only finite accuracy). Therefore, the rendering computations produce random results when trying to decide which one ends first. This is easy to fix. Scale the cylinder mapping to make it shorter using the scale handle and move it so that the mapping is in the middle of the can (see the image below). Render to verify that the mapping works well this time.

Cylinder mapping shortened and centered

9. The logo texture goes all the way around the can which makes visualizing the image hard. So let us make it smaller. Open the property window of the mapping object and go to the Spec tab (make sure that the mapping object is selected and the geometry objects tab is active on the select window). Change the Scale gadget value to '0.25 0.5 1'. Then render again. The width of the logo has become one quarter and the height one half of the original size.

Adjusting the mapping scale

10. Keep the property window open but switch to the Materials tab on the Select window. The property window shows now the controls of the Color Map material. Activate Tile X and render again. The logo pattern now is repeated and travels around the can. You may close the property window now.

11. The stripe of shrunk logo labels appears in the top half of the can, but how do you put it at the center of the can? You might have noticed that the mapping specific properties not only include Scale but also Translate', Rotate', etc controls. You can use the Translate gadget for accurate numeric positioning. However, the mapping geometry itself provides a more straightforward way to place the logo. Simply drag the cylinder mapping downward using its blue translate handle.

Tile X activated

Note that using the unified tools, you can create a cylinder sector map:

Such a sector map allows intuitive control over the mapped area without the need to use numerical scale attributes.

Texture anti-aliasing

Let's experiment a bit more with the logo material created above.

Level: Beginner/Medium

Example file: tutorprojects\material\mapping\antialiasing

Select the Cylinder+Color Map from the object hierarchy and delete it.

Go to the top view and zoom out very far. Select Rectangle from the Analytic tools menu and draw a rectangle which covers the whole view.

Zoom back in to a normal scale. Activate the Materials tab of the toolbar and choose the Parallel mapping tool. Select the Color Map material and draw a parallel map in the view window. The size of the map should be much smaller than the size of the rectangle.

Set the view back to the front view. Go to the Light Sources tab and activate the Ambient light tool. Click Accept. Now the simple test scene is ready.

Go to the Materials section of the select window, activate the Color Map material created in the previous tutorial and open its property window. Tile X is already set but set Tile Y as well.

If the view window is in parallel projection, select Camera/Perspective from the view's popup menu. Rotate the view window upwards and render. The result should look like in the example image.

The logo can be seen well in the front area, but the quality gets worse as the distance grows. Improving rendering quality helps a bit, but any reasonable quality cannot completely remove problems appearing far away from the camera. It is better to modify the material itself to fix this.

Bad anti-aliasing
Adjusting anti-aliasing

In the material's property window check the Advanced option to see the internal structure of the material. The tree-like VSL diagram shows the structure of the material. You can see an item 'Color=Texture(Map coords)'. Select it by clicking it. The lower part of the property window now shows several tabs. Select the General tab.

Set the Anti-aliasing value to 1. It is a good default value to start with. The resolution of the logo image is some hundred pixels in both directions. When such a texture covers only few pixels in the final rendering many samples are needed to compute it. Optimally, the amount of samples should be the amount of details, i.e. the resolution of the image. Usually this would be very slow to compute. Setting the U samples and V samples to 10 tells the renderer to compute 100 (10*10) samples in the densest areas.

Render the view to test the result. If the quality is not good enough at the horizon, increase the anti-aliasing value by one. If the densest areas are well rendered, but there are problematic areas closer to the camera, halve the Threshold value from 1.0 to 0.5. The Threshold defines the minimal texture density where the texture anti-aliasing starts. If these adjustments are not enough to give a good quality everywhere, continue to increase the U and V samples.

Good anti-aliasing achieved