[WML-Source: MaterialTexture.wml][TOC][Part00]

[chapter]Material and Texture

[section]Light and Material Settings by Randall Rickert

Effective material design requires some understanding of how simulated light and surfaces interact in Blender's rendering engine, how material settings control those interactions, and how to work around some limitations of the engine.

The viewing plane is the imaginary surface onto which the image is projected. It is analogous to the film in a traditional camera, or the rods and cones in the human eye. It receives simulated light. To render an image of a scene, we answer this question: what light from the scene is arriving at each point on the viewing plane?

This question is answered by following a line (the simulated light ray) backward through that point on the viewing plane and a focal point (the location of the camera) to a renderable surface in the scene, then determining what light would strike that point. The surface properties and incident light angle tell us how much of that light would be reflected back along the incident viewing angle. See Figure 1.

(DTP: The next pictures are availble as vektor images (*.ai)-cw-)

Figure 1  [images/Material/figure_1.tga]

There are two basic types of reflection which take place at any point on a surface: diffuse reflection and specular reflection. Diffuse reflection and specular reflection are distinguished from each other simply by the relationship between the incident light angle and the reflected light angle.

[subsection]Diffuse Reflection

Light striking a diffuse surface will be scattered, i.e., reflected in all directions. This means that the camera will see the same amount of light from that surface point no matter the incident viewing angle. This quality is why diffuse light is called viewpoint independent. If most of the light striking a surface is being reflected diffusely, the surface will have a matte appearance. See Figure 2.

Figure 2  [images/Material/figure_2.tga]

[subsection]Specular Reflection

Specular reflection, on the other hand, is viewpoint dependent. Light striking a specular surface will be reflected at an angle which mirrors the incident light angle, so the viewing angle is very important. Specular reflection forms tight, bright highlights, making the surface appear glossy. See Figure 3.

Figure 3  [images/Material/figure_3.tga]

In reality, diffuse reflection and specular reflection are exactly the same process. Diffuse reflection is seen on a surface which has so much small-scale roughness in the surface that light is reflected in many different directions by many tiny changes in surface angle. Specular reflection appears on a surface with enough consistency in the angle of the surface that the light is reflected in a consistent direction, rather than being scattered. It's just a matter of the scale of the detail. An automobile's chrome fender normally looks shiny, but from a spacecraft it will appear as part of the diffuse detail of the planet. Likewise, sand has a matte appearance, but if you look at it through a microscope you will see smooth, shiny surfaces.

Blender allows us to easily control how much of the incident light striking a point on a surface is scattered, how much of it is reflected as specularity, and how much of it is not reflected at all. This determines in what directions (and in what amounts) the light is reflected from a given light source or, to look at it another way, from what sources (and in what amounts) the light is being reflected toward a given point on the viewing plane.

How these Concepts Work in Blender

Open the file "shinyball.blend" from the CD-ROM. Go to the material buttons (press F5 ) and look at how Blender handles these concepts. Blender uses the "Ref" slider to control how much diffuse reflectivity a surface has. Blender uses the "Spec" slider to control how much specular reflectivity a surface has. I like to make the sum of the "Spec" setting and the "Ref" setting equal to 1.0, assuming that 1.0 represents the total light being received. I control the pigment, which might absorb some of this light, with the "Color" RGB sliders. It's useful to stick with a sensible system and use several lights in your scene with whatever level of brightness is necessary to get the luminance you want in your scene. See Figure 4.

Figure 4  [images/Material/figure_4.tga]

Press F12 to render the scene. This is a very simple model of surface lighting. It can be effective, but it is incomplete. Images created using this model will lack richness of lighting. Blender has other settings that make this basic lighting model more flexible. See Figure 5.

Figure 5  [images/Material/figure_5.tga]

The biggest deficiency of this model is that it can only simulate light that travels directly from a single-point lamp to a surface to the camera. It does not take into account light which is reflected by more than one surface before reaching the camera, or light emitting from an area rather than a point. A fluorescent panel is an example of a light source that obviously emits light from an area. In truth, every real-world light source emits light from an area or a volume, not a point.

The "Hard" slider lets you soften your specular highlights, making them appear more diffuse while maintaining independent control of purely diffuse reflection. See Figure 6.

Figure 6  [images/Material/figure_6.tga]

Adding an ambient component to the diffuse lighting model is a very "quick-and-dirty" way to simulate the diffuse interreflected light that bounces around in the scene before reaching the camera. The "Amb" slider controls how much ambient light each material will reflect. Every material in your scene should have the same ratio between "Amb" and "Ref". See Figure 6a.

Figure 6a  [images/Material/figure_6a.tga]

The "AmbR", "AmbG", and "AmbB" sliders in the world buttons control the actual amount of ambient light in the scene. The world buttons are accessed by clicking on the icon that looks like a tiny planet. If there is no world linked to your scene (in other words, if no settings appear when you switch to the world buttons), you can add a world by selecting "ADD NEW" from the pull-down menu. See Figure 6d.

Figure 6d  [images/Material/figure_6d.tga]

Their values should correlate to the amount and color of ambient light that would likely be bouncing around, in accordance with the lamps and surfaces in the scene. Blender doesn't take the lamps in the scene into account when rendering this ambient light, so use your imagination to make this decision. This method creates the appearance of light of a single color and intensity coming uniformly from all directions. The lighting tends to appear flat with this method, but it is simple to use and does not increase rendering time. See Figure 6b.

Figure 6b  [images/Material/figure_6b.tga]

See Figure 6c.

Figure 6c  [images/Material/figure_6c.tga]

Additional soft lighting manually placed in the scene can create this illusion in a more subtle and varied way. "Hemi" lamps will produce a low-contrast effect throughout the scene and can be limited to specific parts of the scene using layers. "Lamp" lamps with the "Quad" setting create a very localized effect. These settings are found in the lamp buttons window (F4 ). See Figure 7.

Figure 7  [images/Material/figure_7.tga]

A more accurate automated method to achieve this effect is a process called radiosity. The simulation of light that is reflected from very smooth, specular surfaces (such as polished metal) after traveling around in the scene before reaching the camera, can be achieved by a process called environment mapping. These techniques are replacements for diffuse and specular material settings. Both of these techniques extend the surface lighting model beyond the assumption that the light reflecting from a surface to the camera comes directly from zero-dimensional lamps.

[section]Radiosity by Randall Rickert

First we will generate a radiosity model for the scene. Turn off layer 2, which contains the lights. We don't need them for anything else we will be doing. You can do this by clicking on the second layer in the 3D window while holding SHIFT or by pressing SHIFT-2 . See Figure 7a.

Figure 7a  [images/Material/figure_7a.tga]

The only factors in Blender's radiosity engine are the "Color", "Ref", and "Emit" values of the material settings. See Figure 8.

Figure 8  [images/Material/figure_8.tga]

Switch to the radiosity buttons window (the one with the black and yellow radiation symbol). See Figure 8a.

Figure 8a  [images/Material/figure_8a.tga]

In Blender's radiosity engine, light is emitted not from a single point but from an area (or more likely, from several areas). Polygonal geometry is used to emit light, and the calculated luminance is stored in the polygonal geometry as vertex colors. Blender subdivides the geometry into smaller polygons called patches, which are in turn divided into even smaller polygons called elements. Blender's radiosity engine works by distributing light outward from any patches that have light to emit. Initially, this means patches created from geometry whose material has an "Emit" value greater than 0. The elements in the scene receive this luminance and reflect it by passing excess energy to their patches, which in turn distribute it further. This process continues until you press ESC , until the process has repeated as many times as the value of "Max Iterations", or until the amount of undistributed energy in the scene is less than the value of "Convergence". See Figure 8b.

Figure 8b  [images/Material/figure_8b.tga]

To bring the mesh geometry into Blender's radiosity solver select all (AKEY ) and click the "Collect Meshes" button.

Figure 9  [images/Material/figure_9.tga]

You will see some blue and white squares appear in front of the camera. The blue squares are the minimum and maximum element sizes, the white squares are the minimum and maximum patch sizes. The patch and element sizes determine how finely detailed the radiosity solution will be. Smaller patches increase accuracy of detail (especially for shadowing caused by intervening geometry), but they also increase the time required and are more likely to show artifacts. To get a preview of how finely subdivided your final mesh will be, select the blue "Wire" button to view the data as a wireframe. Then click "Limit Subdivide", followed by "Subdiv Shoot Element" and "Subdiv Shoot Patch". See Figure 9a.

Figure 9a  [images/Material/figure_9a.tga]

In addition to controlling the amount of detail, the other buttons provide control over the completeness of the luminance distribution. In particular, the "Max Iterations" and "Convergence" buttons control how thoroughly the luminance is distributed through the scene. This time we're going to leave the settings at default. Select the green "Gour" button so that as the solution progresses you can see how nice it looks. This is important because the speed of your processor and your level of patience may demand that the calculations be terminated as soon as they look good enough for the purpose at hand. The calculation process can be ended at any time by hitting ESC . Click "Go" to start the process. See Figure 10.

Figure 10  [images/Material/figure_10.tga]

Now go enjoy a beer or a nice meal. Take a nap. Spend time with your loved ones. When the geometry in your scene is complex, the radiosity solution can take a very very long time. In a scene like this, you can take a shortcut in the radiosity solution by using low-resolution "proxy" versions of meshes that are complex but don't have much diffuse reflectivity, then swap them for the high-resolution versions for the final rendering. For example, you could model the car with NURBS surfaces so that you would have high- and low-polygon versions of it at your fingertips simply by changing the U and V resolution and converting them to meshes. A very specular object doesn't show much diffuse light anyway, so you don't need an accurate solution for showing diffuse light on the car. If your smooth curvy object is very diffuse, you just have to put up with the long time necessary for the solution.

One benefit of a radiosity solution is that it only needs to be computed once. You can even adjust the luminance and luminance curve of the entire solution after it is calculated using the "Mult" and "Gamma" buttons, as long as you are happy with the balance between the various light sources. This must be done before bringing the newly created mesh from the radiosity solver into the scene. For this scene, I used a "Gamma" value of 2.25 to adjust the luminance curve of the solution. If you know the gamma of your monitor, try using that value as a starting point. To quickly get an idea of the overall look of the lighting, take just the room into the solution with the largest settings for patch and element sizes and run the solution for a very short while. Click the "Free Radio Data" button to remove all of the data from the radiosity solver, adjust your material settings, and try again. When you are happy you can bring all of the models back into the solver and let it work overnight. See Figure 11.

Figure 11  [images/Material/figure_11.tga]

When you like the results, click the "Add New Meshes" button to copy the new radiosity-enhanced meshes from the radiosity solver into the scene, then click "Free Radio Data" to empty the solver. The new meshes will be added to the highest active layer (in this case, layer 6). Move the new mesh data (press M ) to layer 3 so you can keep it separate from the old objects. In the 3D window, turn off layer 1 and turn on layer 3.

Blender has created the radiosity solution as a single mesh. In order to re-apply your materials to the models, you will need to either separate the mesh into a number of separate objects, or to create a discrete material index for the section of the mesh corresponding to each material. I like to separate the mesh into objects so that I can easily place them on different layers. This will be useful when we come to the environment mapping section. We will go through the separation process now.

With the new mesh selected, enter edit mode (TAB ). Holding your mouse over a vertex of the first section you want to separate, select the vertices linked to it by pressing LKEY . Any groups of polygons that were not "Set Smooth" in the edit buttons before being brought into the radiosity solver and are not planar with neighboring faces will be split from their neighbors. Separate the selected vertices using P ->SEPARATE. Continue this process for each part you want to separate. Create a discrete object for each material. We need to be able to link the materials to these new objects, and using material indices is too difficult with so many vertices. With curved meshes (such as the ball), go to the edit buttons (F9 ) and click "Set Smooth" after you have separated them from the large mesh.

Now link the materials to the new objects as usual. Finally, make sure that your materials all have "VCol Light" selected (but not "VCol Paint", so that the rendering engine treats the vertex colors as precalculated light. At this point, you should be able to go into textured preview mode (alt-z) and see your scene with the diffuse lighting, and also render the scene (f12) and see everything lit with diffuse lighting, even though you have turned off the layer with all of the lights! The file "shinyball_rad.blend" is how your scene should look with radiosity. See Figure 12.

Figure 12  [images/Material/figure_12.tga]

The important thing to remember is that light should function the same whether it comes directly from a lamp or is being reflected from another object, and no light source could really be a single point. Therefore light will behave better if it's being emitted from some geometry. We've already addressed these issues for simulating diffuse light, and now we will do the same thing for specular highlights.

[subsection]Environment Maps

Now on the shiny surfaces we will put some highlights that are a bit visually richer than the standard Phong specular highlights. The ironic thing about Phong surfaces is that they are like mirrors that show you things you ordinarily can't see, but none of what you ordinarily can see. What I mean by this is that Phong surfaces show you a bright spot as a mirror-like reflection of a lamp. This makes sense, except that if you turn the camera directly toward the lamp, you won't see it! The camera sees this light only if it is being reflected by a Phong surface, not directly. On the other hand, objects that appear very bright in your scene (i.e.: they reflect a lot of light to the camera) don't show up in these highlights. This looks especially strange when some of the bright objects should throw more light than some of lamps, but in the specular highlights only the lamps are visible. It is easy enough to make a lamp which is directly visible to the camera by placing some renderable object in the scene which looks like some appropriate sort of lamp fixture, flame, sun, etc. However, wide light sources should appear as wide highlights when reflected, but the shinier the Phong surface is, the smaller the specular highlight will be. This is the sort of problem we will address using the technique of environment mapping.

Just as we render what light is reaching the viewing plane using the camera to define a viewpoint, we can render what light is reaching the surface of an object (and hence, what light might ultimately be reflected to the camera). Blender's environment mapping renders a cubic image map of the scene in the six cardinal directions from any point. When the six tiles of the image are mapped onto an object using the "Refl" input coordinates, they create the visual complexity that the eye expects to see from shiny reflections. It's useful to remember here that the true goal of this technique is believability, not accuracy. The eye doesn't need a physically accurate simulation of the light's travel; it just needs to be lulled into acceptance by seeing the complexity it expects. The most unbelievable thing about most rendered images is the sterility, not the inaccuracy.

The first step for creating an environment map is to define the viewpoint for the map. Add an empty to the scene and place it in the center of the ball. Ideally, the location of the empty would mirror the location of the camera across the plane of the polygon onto which it is being mapped. It would be ridiculously difficult to create a separate environment map for every polygon of a detailed mesh, so we take advantage of the fact that the human eye is very gullible. The decision about where to place the empty is more critical when the reflective geometry is more or less a large flat surface, such as water. Since the ball bears little resemblance to a large flat surface, we can get away with simply placing the empty near the center. Name the empty "env" so we can refer to it by name in the environment map settings.

Select the ball and go to the material buttons. Add a new texture by selecting "Add New" from the texture pull-down menu. See Figure 12a.

Figure 12a  [images/Material/figure_12a.tga]

Go to the texture buttons with F6 . Select "EnvMap" as the texture type. In the "Ob:" button, type "env". The "ClipSta" and "ClipEnd" settings work just like the similarly named settings for a camera. If the objects you want see in the environment map do not fall within that range of distances from the empty's location, increase this value. The default range of 0.1 to 100.0 works well for the demo file.

Move the ball to layer 4, and turn on layer 4 in the 3D window. The buttons marked "Don't render layer" determine what layers are not rendered as part of the environment map. This is very important, because it's necessary to prevent the object to which the environment map will be applied from being rendered in the map. Otherwise, instead of reflecting the environment around the ball, the ball will reflect its own interior. Select the fourth layer, which contains the ball, from among these buttons. See Figure 13.

Figure 13  [images/Material/figure_13.tga]

If you want the environment map to be re-rendered every time you render the scene, select the green "Anim" button. In an animation, this setting causes the environment map to be re-rendered for every frame of the animation so that it looks correct. If you select the "Static" button instead, the environment map will only be created the first time the scene is rendered. This will speed up subsequent renderings of the scene and will save time if you are making lots of test-renderings. However, any changes you make to the scene will not show up in the environment map after the first time you render. If you make changes to the scene and you want the environment map to be re-rendered, press "Free Data". You can save the environment map to a file with the "Save EnvMap" button so that it can later be re-used by loading it with the "Load" button. See Figure 13a.

Figure 13a  [images/Material/figure_13a.tga]

Go back to the material buttons. Change the input coordinates for the environment map texture from "Orco" to "Refl". If we were using standard lamps to provide the diffuse light in this scene, we could select the "Cmir" texture output button and deselect the "Col" button. We would set the "Col" slider at the bottom of the texture output buttons to 0.7, because the "Ref" setting is 0.3 (using the formula Spec + Ref = 1). However, Blender's vertex light has an idiosyncracy that we must circumvent: Textures mapped to "Cmir" do not behave well with vertex light. The solution is to add the texture's output to the material's color and emit values. To do this, select the "Col", "Emit", and "Add" texture output buttons. Set the "Col" slider at the bottom of the texture output buttons to 0.2 (this controls how much "Col" is added) and set the "Var" slider to 0.1 (this controls how much "Emit" is added). Render the scene. The finished product will look something like "shinyball_env.blend" . See Figure 14.

Figure 14  [images/Material/figure_14.tga]

[section]Refraction in Solid and Hollow Glass by Randall Rickert

We've looked at how we can create a better reflection of an object's environment. Now let's look at another use for environment maps: simulating refraction.

Open the file "glass.blend" . We will make the blue sphere look like a solid ball of glass, so we need to create the appearance that light is bending as it passes through. We expect to see the objects behind the sphere heavily warped, as if through a very thick lens. Blender lets us achieve this effect by inverting the environment map and doing some wacky tricks with transparency and procedural textures.

[subsection]Faking Refracted Transparency

Set up an environment map for the sphere's material the same way we did for the ball in the last tutorial, with an empty to locate the environment map's perspective at the center of the sphere. This time, however, we will use the "Cmir" output button with "Mix", as the vertex color light which was problematic in the radiosity tutorial is not present in this one. We make some changes to the output mapping with the "ofsZ", "sizeX", "sizeY", "sizeZ" and "Col" sliders to warp the map in a way that looks like refraction. Use the following settings for the texture output: See Figure 15.

Figure 15  [images/Material/figure_15.tga]

Select the "Mir" RGB material sliders and lower the "R" and "G" a bit to give a blue tint to the texture. Experience with the idiosyncrasies of Blender's handling of mirror colors dictates this unintuitive approach when combining environment-mapped reflections and refractions in a single material. Turn the "Ref" slider all the way down. See Figure 16.

Figure 16  [images/Material/figure_16.tga]

You now have a blue-tinted refraction of the environment. Shiny glass also needs a reflection map, so place the same texture into another texture channel. Press the "Add", "Col", and "Emit" buttons, and use the "Refl" button for the coordinates. Make the material "Color" black and turn "Emit" all the way up. Don't ask any questions - just trust me! See Figure 17.

Figure 17  [images/Material/figure_17.tga]

Finally, in order to get the refraction texture back to a nice blue tint again, we have to add a new texture, leaving the texture type set to "None". Select the "Mix" and "Cmir" buttons, and set the "Col" slider about halfway up. Click the "Neg" button and set the texture input RGB sliders to a dark blue. See Figure 18.

Figure 18  [images/Material/figure_18.tga]

The result should look like "solidglass.blend" . The refraction effect is most noticeable when the scene is animated. Render and enjoy. See Figure 19.

Figure 19  [images/Material/figure_19.tga]

That's fine for a solid lump of glass, but how do we go about making hollow-looking glass such as you might need for making a vase? Thin glass has strong refraction only where it slopes away from the eye at a steep angle. We can easily mimic this effect by using Blender's "Blend" texture to control the object's transparency, plus another transparency texture to keep the bright highlights visible.

[subsection]Procedural Transparency Mapping for Hollow Glass

Add a new texture to the material. Select "Blend" as the type and select the green "Sphere" option. Go back to the material buttons, select "Nor" as the mapping type, and disable the X and Y axes in the input coordinates. "Mix" the texture with "Alpha". Move the "Alpha" material slider to 0.0 and set the blue "ZTransp" option. See Figure 20.

Figure 20  [images/Material/figure_20.tga]

This gives nice transparency as the surface angles toward the eye, but we want the bright environment-mapped reflections to show up on those otherwise-transparent areas. If you look at glass windows, you will see that bright light reflecting from the surface will be visible and prevent you from seeing through a pane that is ordinarily transparent. We can do this easily by selecting the environment-mapped reflection texture in the material window and enabling the "Alpha" option. See Figure 21.

Figure 21  [images/Material/figure_21.tga]

That's all there is to it. The result should look like "hollowglass.blend" . See Figure 22.

Figure 22  [images/Material/figure_22.tga]

[section]Rippled Water by Randall Rickert

Creating an environment map for an object that is planar or roughly planar requires us to modify our approach to locating the perspective of the map. Open the file "water.blend" , and we will go through the steps for making a plane look like water. The scene is similar to "glass.blend" .

[subsection]Locating Planar Environment Map Perspective

Add an environment map texture to the material of the green plane just as in the previous tutorials. Give the texture a descriptive name, such as "envMap". In fact, it is good practice to name all of your textures descriptively so that you can easily identify them. Once again, select layer 2 in the "Don't Render Layer" section in the texture buttons. This time, we will place an empty in a position that mirrors the position of the camera across the green plane. Now enter the name of the empy in the "Ob:" textfield

Switch to front view in the 3D window (NUMPAD_1 ). Select the camera and snap the cursor to the location of the camera by pressing SHIFT-S 4KEY . Add an empty. It will be created at the camera's location. Name the empty "env". Select the green plane and snap the 3D cursor to it (as above).

We want to use the 3D cursor as the pivot point for our next operation. This can be done by pressing PERIOD . Select the empty. Take your hand off of your mouse so that it doesn't move at all. This is necessary for creating the environment map accurately. Press SKEY to use the scale tool, then YKEY to mirror the empty across the 3D cursor along the Y-axis of the current view. Before touching your mouse again, press ENTER . At this point you should see the empty below the plane, mirroring the position of the camera that is above the plane. See Figure 22a.

Figure 22a  [images/Material/figure_22a.tga]

Select the green plane again. Switch back to the camera view (NUMPAD_0 ). In the material buttons window, use the "Refl" and "Cmir" texture mapping buttons (deselect the "Col" button). See Figure 23.

Figure 23  [images/Material/figure_23.tga]

If you render the scene, you will see that the environment map makes the plane look like a blurry mirror. Let's get rid of some of the blur by turning up the value in the "Cube Res" number button in the texture buttons window. See Figure 24.

Figure 24  [images/Material/figure_24.tga]

Go back to the material buttons window. Lower the "Col" texture output slider so that the environment map won't be the only color visible. See Figure 25.

Figure 25  [images/Material/figure_25.tga]

Lower the "Ref" material slider. Raise the "Spec" and "Hard" sliders. See Figure 26.

Figure 26  [images/Material/figure_26.tga]

Finally, let's turn on the "Mist" setting in the world buttons window to make the plane fade out toward the horizon, instead of ending abruptly. The "Sta" and "Di" settings determine how far from the camera the mist starts and ends, respectively. The "Qua" button means that the mist will have a quadratic progression, appearing very dense very quickly near the limit of the mist distance (the value of "Di"). See Figure 27.

Figure 27  [images/Material/figure_27.tga]

The result should look like the file "water_env.blend" . See Figure 28.

Figure 28  [images/Material/figure_28.tga]

It certainly looks like a large reflective surface of some sort, but it needs some ripples in order to be convincing. We don't need to change the actual geometry of the surface to create the illusion of ripples. We can accomplish the effect using bump mapping. Blender has a procedural texture that is designed for this.

[subsection]Procedural Bump-Map Ripples

With the plane selected, go to the material buttons window again. Add a new texture, and in the texture buttons window, select "Stucci" as the type. Select the "Wall Out" button to create somewhat "pointy" ripples. See Figure 29.

Figure 29  [images/Material/figure_29.tga]

Switch back to the material buttons window. Select the "Glob" and "Nor" texture output buttons, and de-select "Col". See Figure 30.

Figure 30  [images/Material/figure_30.tga]

Render the scene. If you created the environment map texture in the first slot of the material's texture list and the bump map texture in the second slot (as I did), you will see that the bump map is visible in the specular highlights, but it is not affecting the environment map. This is because the textures are calculated in the order in which they appear in the material buttons window (from left to right). We have to make the environment map follow the bump map. Fortunately, Blender has a facility for just such texture manipulation. We can easily copy the texture link and all of the settings associated with it to a different slot in the material's texture list.

Select the environment map texture. Click the button with the upward arrow at the right end of the texture list. The button which pops up informs you "copied!". You can click the button to dismiss it, or just hit ESC or move your mouse. It doesn't matter what you do with the button. It's just there to inform you. With the environment map texture still selected in the texture list, unlink the texture from the material by clicking the "Clear" button in the texture linking buttons. See Figure 31.

Figure 31  [images/Material/figure_31.tga]

Now select a slot to the right of the bump texture and click the button with the downward arrow at the right end of the texture list. You will see another confirmation button, this time informing you that the texture and its settings have been pasted into the selected slot in the texture list. See Figure 32.

Figure 32  [images/Material/figure_32.tga]

It's giving us the right effect now, so let's fine-tune the bump texture settings to make it look a bit nicer. Select the bump texture again in the list. Push the "Nor" slider up to 2.0 and change the "SizeX" and "SizeY" number buttons to a value of 0.5. See Figure 33.

Figure 33  [images/Material/figure_33.tga]

The result should look like "water_bump.blend" . See Figure 34.

Figure 34  [images/Material/figure_34.tga]

This makes a nice still image, but it's much more fun when animated. One of the benefits of procedural textures is that they can be easily animated.

[subsection]Animating the Procedural Texture

Go to frame 1. If you are not on it, you can jump to it by pressing SHIFT+LEFT_ARROW . You can see the current frame number in the frame number button. See Figure 35.

Figure 35  [images/Material/figure_35.tga]

The first thing we will do is to insert a material key on this frame. With the bump map texture selected and with your mouse somewhere over the material buttons window, press IKEY >Ofs. See Figure 36.

Figure 36  [images/Material/figure_36.tga]

We will now insert a material key on the last frame. Switch to the last frame by pressing SHIFT-ARROW_RIGHT . In the demo file, the last frame is 31. Change the value in the "OfsX" number button to 0.8 and the value in the "OfsZ" number button to 0.2. The "OfsX" change will make the ripples appear to drift sideways, and the "OfsZ" change will make the ripples change shape, so it doesn't look like the entire water surface is simply sliding sideways. The "OfsZ" change works becuase the "Stucci" texture varies in the Z direction as well as in the X and Y directions. See Figure 37.

Figure 37  [images/Material/figure_37.tga]

Insert a keyframe exactly as above. If you don't set a keyframe, the changes you made to the texture output values will be lost.

Blender smoothly interpolates between these two keys by using a Bezier equation. To see the curve described by this equation, click the material icon in the IPO window. Next to it a number button will appear, which correlates to the position of the texture in the material's texture list. It probably says "0". Change the number to 1. See Figure 38.

Figure 38  [images/Material/figure_38.tga]

Press HOME with your mouse over the IPO window to see the best view of the curves. You will see that the translation of the texture will start and end smoothly. In contrast, what we want is for the texture to show a constant (linear) change, with the slope defined by the two keys we set. This is accomplished with the constant slope button at the base of the IPO window. To find this button, you may need to move the header at the bottom of the window to the left by dragging it with the middle mouse. SHIFT+LEFT_CLICK the colored buttons next to "OfsX" and "OfsZ" in the list of keyable attributes on the right side of the IPO window, then click the constant slope button. Your curves should straighten out. See Figure 39.

Figure 39  [images/Material/figure_39.tga]

Your scene file should now look like "water_anim.blend" . Click the "Anim" button in the render buttons window to render the entire animation. Make sure that the render directory is valid and that you have selected a file type that your system can play back. The "Extensions" button will ensure that the names of your rendered files have file type extensions in them, in case your system or your other applications use the extensions to determine file types. See Figure 40.

Figure 40  [images/Material/figure_40.tga]

The resulting animation should look like "water_anim.mpg" .

[section]Halomaterial and Lensflares


Halomaterials are most often used for particle systems (see that section). But they are also good for creating some special effects, e.g. to make an object glow, or to make a viewable light source. Here I will show you how to use a halomaterial to make a dotmatrix display.

Add a grid with the dimensions 32x16. Add a camera and adjust your scene in such a way that you have a nice view of our billboard. Now use a 2D image program to create some red text on a black background, and use a simple and bold font. I created an image 512 pixels in width by 64 pixels in height, with some black space at both sides.

"BlenderDotMatrix2.tga"   [images/BlenderDotMatrix2.tga]

Now add a material for the billboard, and set it to the type "Halo". Set the HaloSize to 0.06 and render, you will see a grid of white spots. Now switch to the TextureButtons and add a new image texture. Load your picture and render again, you will see some red tinted dots in the grid. Go back to the MaterialButtons and adjust the "sizeX" parameter to about 0.5 and do a render again, the text should now be centered on the Billboard.


To get rid of the white dots, adjust the material color to a dark red and render again. We have now only red dots, but it is still too dark. We can fix this by entering EditMode for the board and by copying all vertices unsing the SHIFT-D shortcut. We can now adjust the brightness with the "Add" value in the MaterialButtons.


You can now animate the texture to move over the billboard, with the "ofsX" value in the MaterialButtons. An example is located in the file "DotMatrix.blend" on the CD. Of course, you can also use a higher resolution for the grid, but then you will have to adjust the size of the halos (HaloSize).
We have not used the "HaloTex" option here. This option will map the whole image to every halo. This is very usefull when you want to create a realistic rain effect using particle systems, or similar.

[subsection]Lens flares

Our eyes have been trained to believe an image if it shows familiar artifacts from the mechanical process of photography. `Motion blur' and `lens flares' are just two examples of these artifacts. A simulated lens flare tells the viewer that the image was created with a camera, and it is therefore `authentic'.

In Blender, a lens flares is created from a mesh object using the "Halo" and "Flare" options in the material settings. Try turning on "Rings" and "Lines", though I would recommend that you keep the colors for these settings fairly subtle. Play with the "Flares" and "Fl.seed" settings until you arrive at something that is pleasing to the eye. This tool does not simulate the physics of photons traveling through a glass lens; it's just a eye candy. See Figure 1.

Figure 1  [images/Lensflare/figure_1a.tga]

An example of this technique can be seen in "lensflare.blend" . See Figure 2.

Figure 2  [images/Lensflare/figure_2.tga]

Blender's lens flare looks nice in motion, and disappears when another object occludes the flare mesh. Look at "lensflare.mpg" on the CD.


Most objects are assembled so that they can be modeled in parts, which then will be attached to each other. Some objects need more materials, but at least it is easier to have two or more materials on one mesh. With textures this facility is even more important.

A simple example is a dice with six different textures that show the points. Make a cube and add a material to it. Make the mapping "Cube". If you want to use the textures from the CD, then switch on "Neg" in the texture color settings and activate also "Nor" for the texture mapping output. Now, add an image texture to the material and choose the image with the one point. A rendering should give you a dice with only one point on every side.


Now switch one 3DWindow to a side view and enter EditMode for the dice. Go to the EditButtons F9 and look at the multi material buttons. They show the name of the actual material ("Dice1"), and the "1 Mat 1" means that you have selected the first material from a total number of one materials.


Now click on "New" and the buttons changes to "2 Mat 2". Now select the top vertices of the cube with the BorderSelect (BKEY ) and click on "Assign". This will assign material number two to the selected vertices.
"Select" and "Deselect" allowing you to select all vertices with the indicated material.


Leave the EditMode and go back to the MaterialButtons. Here you will find a similar "2 Mat 2" button. The material has now two users, indicated by the blue color in the name of the material and the number button showing "2".


Click on the "2" and confirm the "OK? Single user" question, then rename the material to "Dice2". Now go to the TextureButtons for that material and make the texture single user as well. Load the texture with the two points on it. When you render, you will see that the top of the dice has the new texture assigned. The other sides will have remained unchanged.


Repeating the steps you can now assign every side a different material and texture.


In Blender, the Materials and Textures form separate blocks. This approach was chosen to keep the interface simple and to allow universal integration between Textures, Lamps, and World blocks. The relationship between a Material and a Texture is called the 'mapping'. This relationship is two-sided. First, the information that is passed on to the Texture must be specified. Then the effect of the Texture on the Material is specified. The MaterialButtons on the right-hand side (and the Lamp and World buttons) are reserved for the mapping. The buttons are organized in the sequence in which the 'texture pipeline' is performed. (DTP: the next pictures can also be done like on page 134 in the old manual (connected with arrows, numbered)-cw-)
  1.   [images/TextureChannelsHoriz.tga]

    Texture channels. Each Material has eight channels to which Textures can be linked. Each channel has its own individual mapping. By default, textures are executed one after another and then superimposed. A second Texture channel can completely replace the first one.

  2.   [images/MaterialCoordInput.tga]

    Coordinates input. Each Texture has a 3D coordinate (the texture coordinate) as input. The starting point is usually the global coordinate of the 3D punt that can be seen in the pixel to be rendered. A Material has a number of options for this, allowing you to create animated or reflecting textures.

  3.   [images/MaterialTextureMapping.tga]

    3D to 2D conversion. Only for Image Textures; this indicates the way in which the 3D coordinate is converted to 2D. The options include flat, spherical and cubical methods.

  4.   [images/MaterialTextureSwitch.tga]

    Coordinates switch. Switches between the X, Y or Z coordinates, or turns them off.

  5.   [images/MaterialTextureTransform.tga]

    Coordinates transform. The texture coordinate can be given an extra translation or scaling.

  6.   [images/LampTextureBlock.tga]

    The Texture itself. Only the name of the Texture block must be specified.

  7.   [images/MaterialTextureInput.tga]

    Texture input settings. A number of standard settings for the Texture, plus specification of the effect of the current Texture on the next one.

  8.   [images/MaterialTextureOutput.tga]

    Mapping: output to. All prior data is used to change parts of the Material. Textures can therefore have an effect not only on color, but on the normal (bump mapping) or the "Alpha" value as well.

  9.   [images/MaterialTextureOutputSettings.tga]

    Output settings Indicates the strength of the effect of the Texture output. Mixing is possible with a standard value, addition, subtraction or multiplication.

Textures give three types of output: A distinction is also made between 2D textures and 3D (procedural) textures. "Wood", for example, is a procedural texture. This means that each 3D coordinate can be translated directly into a color or a value. These types of textures are 'real' 3D, they fit together perfectly at the edges and continue to look like what they are meant to look like even when cut; as if a block of wood has really been cut in two. Procedural textures are not filtered extra or anti-aliased. This is hardly ever a problem: the user can easily keep the specified frequencies within acceptable limits.


The colorband is an often-neglected tool in the texture buttons window (F6 ). It gives you an impressive level of control over how procedural textures are rendered. Instead of simply rendering each texture as a linear progression from 0.0 to 1.0, you can use the colorband to create a gradient which progresses through as many variations of color and transparency (alpha) as you like.

To use it, select a procedural texture, such as "Wood". Click the "Colorband" button. The "Colorband" is Blender's gradient editor. Each point on the band can be placed at any location and can be assigned any color and transparency. Blender will interpolate the values from one point to the next.

Select the point you want to edit with the "Cur:" number button. Add and delete points with the "Add" and "Del" buttons. The RGB and Alpha values of the current point are displayed, along with the point's location on the band. Dragging with the left mouse can change the location of the current point. See Figure 1.

Figure 1  [images/Colorband/figure_1.tga]

In the file "colorband.blend" , I am using two "Wood" textures to make ring patterns in two different scales which have different effects on the appearance of the wood. The "Wood" textures are identical except for the way they are mapped in the material buttons window, and the different color bands used. I am also using a "Clouds" texture to make a grain pattern. To see the result of just one texture, isolated from the others, select the "Sept" button. See Figure 1a.

Figure 1a  [images/Colorband/figure_1a.tga]

Here you can see the three individual textures which, when combined in a single material and mapped to various material parameters, creates a nice wood texture.

The "bigRings" texture... (see Figure 1b)

Figure 1b  [images/Colorband/figure_1b.tga]

...plus the "smallRings" texture... (see Figure 1c)

Figure 1c  [images/Colorband/figure_1c.tga]

...plus the "grain" texture... (see Figure 1d)

Figure 1d  [images/Colorband/figure_1d.tga]

...produces the wood material. See Figure 2.

Figure 2  [images/Colorband/figure_2.tga]


The Image texture is the only 2D texture and is the most frequently used and most advanced of Blender's textures. The standard, built-in bump mapping and perspective-corrected mip mapping, filtering and anti-aliasing guarantee outstanding images (set DisplayButtons->OSA to ON for this). Because pictures are two-dimensional, the way in which the 3D texture coordinate is translated to 2D must be specified in the mapping buttons.


There are four types of mapping "Flat", "Cube", "Tube" and "Sphere". Depending on the overall shape of the object, one of these types is most useful.


The Flat mapping gives best results on single planar faces, it also gives an at least interesting effect on the sphere, but compared to a sphere-mapped sphere it looks flat. On faces not in the mapping plane the last pixel of the texture is repeated, this results in the stripes on the cube and cylinder.


The cube-mapping gives often the most useful results when the objects are not too curvy and organic. But notice the seams on the sphere.


The tube-mapping maps the texture around an object like a label on a bottle. The texture is therefore more stretched on the cylinder. This mapping is of course very good for making the label on a bottle or assigning stickers to rounded objects. This is not a cylindrical mapping so the ends of the cylinder are undefined.


The sphere-mapping is understandably the best type for mapping a sphere, it is perfect for making a planet and similar stuff. Often it is also very useful for organic objects. It also gives an interesting effect on the cylinder.

As described in the previous section you can manipulate the texture in the texture part of the MaterialButtons. There is one important feature to manipulate the textures.

When you select an object and press TKEY , you get the option to visually scale and move the texture space. But you cannot rotate the texture here. Besides this shortcut, we also have an even more powerfull function for manipulating our textures.


You can use every object to deliver the size, location and rotation for other objects textures! Empties are very good for that. I use often cubes as input for the textures of a collection of objects. This way I can have a renderable preview of my textures, and use the same mapping on many different surfaces, e.g. the walls inside a building.

[section]Texturing with the UV-Editor


The UV-Editor allows you to map textures directly on the faces of Meshes. Each face can have an individual image assigned to it. These textures can be combined with vertexcolors to tint the texture or to make it brighter or darker. It gives you the absolute control over the mapping, but it does involve more work than the automatic mapping described in the previous section. A UV-textured example of that scene can be found in layer six in the file "Mapping.blend" .

For each face, the use of the UV-Editor adds two extra features:

  1. Four UV coordinates. These define the way an image or a Texture is mapped on the face. They are 2D coordinates, which is why it is called UV to distinguish it from XYZ coordinates. These coordinates can be used for rendering, and for the realtime OpenGL display for previewing and the game engine.
  2. A link to an image. Every face in Blender can have a link to a different image. The UV coordinates define the way in which the image is mapped to the face. The image can then be rendered or displayed for preview and the game engine.

[point]Assigning images to faces

Add a mesh object to your scene. This can be a simple cube or a model created with the help of the texture which we want to use later for texturing. Take a look at the "A Logo with Curves" tutorial to see how to use images as a modeling helper. Here I am using a simple (low poly) mesh of a fish (the fish is on the CD and is entitled: "UVTexFish00.blend" ). We can use that object later as an object for particle effects, or as an object for gameBlender.

Select the mesh object and press FKEY . Blender now enters the face select mode for the active 3DWindow. Alternatively, you can use the icon in the 3DWindow header.

Your mesh will now be drawn z-buffered. When you enter the textured draw mode, with ALT-Z , you see that your object will be drawn in purple. This color indicates that currently there is no texture assigned to our mesh. It also helps to find untextured faces in complicated objects. All selected faces have a dotted outline, so when you now press AKEY , all the faces will be selected.

Change one window to a ImageWindow using SHIFT-F10 . Click on "Load" to get an ImageWindow, then browse for the texture "Fish_a.rgb" on the CD and load it with MMB .

All of the supported image formats that Blender can read are suitable for the UV-texturing, just so long as the size is to a power of 64. This is a limitation from OpenGL.


The object will now look a little odd, but that's because the initial mapping of the image has mapped the image on to every single face.

To give you a start for the texturing, move the mouse over the big 3DWindow (a front view), select all faces with AKEY (if there are still some faces selected you will have to press AKEY twice) and then press UKEY to call up the "UV Calculation" menu.


Choose "From Window" and the vertices with the shape of the fish will appear in the ImageWindow. Here you can select vertices with the right mouse button and move, scale, and rotate them. Every point consists of at least two vertices because we shall want to texture both sides of the fish. So, it's best to use the rectangle selection (BKEY ) to select vertices.

Begin by selecting select all vertices and use the move (GKEY ), rotate (RKEY ) and scale (SKEY ) to fit the fish roughly to the image. Then select individual corners to fit it perfectly to the image. It helps here to switch the front view into the textured drawmode using ALT-Z . Click on the lock-icon to get instant feedback in the 3DWindows when you move vertices in the ImageWindow.

We also can use VertexPainting to adjust the brightness of the fish, or even to tint the color of the texture. For this, switch to VertexPaintMode with VKEY , or use the icon in the 3DWindow-header. Switch to the Face/PaintButtons , choose a color with the color sliders, and then fill the mesh with SHIFT-K .
Use the VertexPainting to adjust the brightness of the texture, or to match the lighting of the texture to your scene lighting


The image also contains some Alpha-channel information, but we will need to tell Blender to use it. Select all of the faces that build up the fins of the fish. You will need to switch to a back-view to make the selection of faces on the back side of the fish.
You can switch from face select mode to EditMode by using TAB . Do your selection here and, after leaving EditMode, you will see the faces build up by the vertices that have been selected
In the Face/PaintButtons, activate "Alpha" and press the "Copy DrawMode" button to copy the draw mode from the active to all selected faces. You should now immediately see the effect in the textured views; the fins will now be partially transparent.
The OpenGL realtime preview draws only one-sided faces, so depending on the direction of the view, faces can disappear. This does not affect a rendering, but for the realtime view, choosing the option "Twoside" will solve this.

[point]Rendering and UV coordinates

Even without an image assigned to faces, you can render textures utilizing the UV coordinates. For this, use the green "UV" button in the MaterialButtons. If you want to render the assigned texture as well, press the "TexFace" button. Of course, you can combine that with the "VertexCol" option in order to use vertex colors.
Often a material with the "Shadeless" option works best for image textures, when the lighting in it does not differ too much from the scene lighting.

With the "UV" button, you can also use the UV coordinates to map Nor and Alpha maps on a object. For more detail refer to the material settings in the file "UVTexFish07.blend" .

-cw- Last modified: Wed Nov 1 18:02:14 CET 2000