Doc:Tutorials/Materials/BSoD/part1j

From BlenderWiki

Jump to: navigation, search

[edit] Image textures

As with any decent 3D suite you need a way of applying photographs, or graphic images, created in a separate paint package, to a material simulation. Blender is no exception and has some wonderful tools that make the job easy.

There are 2 strategies for applying an image to a texture.

  • Standard image mapping - where a picture is projected onto a surface from a single direction, and
  • UV mapping - where a mesh is unwrapped to a flat surface upon which the image is placed. This method allows every face of a mesh to receive the image.

UV mapping is the preferred method of mapping for professional work. It is however, very complex and tricky to use effectively. Distortion and differences in scale across the required image can be problematic. Therefore great experience is required to get it right. For that reason we will not be dealing with UV-Mapping in this beginner’s tutorial which would probably require a complete section on its own. However, before you can even consider UV-mapping you have to know how to map a straight image texture to material. Learn this method and UV mapping will become easier to understand.

[edit] Mapping an image to a surface

Plain image mapping can use one of 4 methods to project an image onto a surface.

caption Blender Mapping types.


  • Flat – which projects the image on the Z axis of the object? The easiest way to think of this is like a texture up or down onto a ground plane.
  • Cube – Here the flat image is projected on each axis. Therefore a cube would receive the same image on each of its six sides.
  • Tube – As its name suggest the image is projected around the Z axis of the object from a central point. In other words the projector pans around the tube.
  • Sphere – Here the image is projected from a central point in all directions.

Obviously there will inevitably be some distortion if the object is not a perfect square plane, cube, tube or sphere. You might think that the best mapping for a human face might be the Sphere type. However, the human face has annoying bumps and hollows; nose, ears, chin, and eye sockets, that will distort the sphere type map.

That’s why for such complex shapes it is best to use UV mapping.

Combined color/spec map with UV outline from Elephants Dream


Fortunately we only need to map a simple image to a plane. We can therefore use Flat mapping with no distortion. However we also need to position and scale the coffee cup mark. In other words place it exactly where we want. Let’s start by adding a new texture to our desktop material.

  • With the desktop object selected press F6 to change to the Texture Button.
  • Select the next free available texture slot and select the Add New button.
  • from the available Texture Type rollout select Image.


This is the image we will use for the coffee stain.

Click for a larger version of this file.


It was created, as explained earlier, by scanning a real coffee stain on paper and adjusting the contrast in a paint program. It was also converted to greyscale and negative . We will use Blender Materials to add color later.

Select the image above to get the fullsize version. Then Right click the image in your browser to download it to your blender directory.

NOTE:
Although you can save and use image files anywhere on your system it’s a good idea to put them into a directory structure that will make it easy to find them for future projects. In my case I have created a pictures folder below the folder that holds my blendfile.



  • From the Image tab select Load Image and locate the coffee-stain1.jpg file.

I will explain the settings in a moment but for now those shown are the defaults which is not a bad place to start.

Note: Although it's not highlighted in the picture above be sure to click clip. If the default repeat is select, your image will be tiled on your mesh.


Return to the Materials button F5 so that we can set how the image will be mapped to the desk surface.

[edit] Orienting and Scaling an Image Texture to a surface


These are the defaults apart from setting the mixing mode to Add. In a moment I will explain the mixing modes in detail but for now the reason I have set it to Add is so that it will be clearly seen on the desk surface.

  • Press F12 to render the scene.


As you can see the coffee stain has lightened the desk surface. But it is far too big, unless I have a serious coffee addiction.


The image has been mapped to fill the whole of the mesh plane. For our purposes we need to change the size, or scale, of the image and position it on the desktop in an appropriate place.

We can change the scale and position of an image texture by altering the sizeX,Y,Z and ofsX,Y,Z in the Map Input tab of the Material button.

There are several ways in which you can position and scale an image texture to a surface. You will learn other methods later but the one I show here will help explain further the Map Input switches and their uses.

[edit] Map Input

Currently the image is mapped to the whole of the mesh co-ordinates. This means that an object has its own material co-ordinates, usually aligned and scaled to the object but it is possible to change that.

This type of mapping is called Orco(ORiginal COordinates) in Blender and is the default. As you can see from the Map Input settings there are quite a few others available. These are explained in the Blender documentation.

http://mediawiki.blender.org/index.php/Manual/PartIV/Map_Input.

However, here are some other useful attributes of these map input types.

  • Glob(al)
    • As its name suggests the material will be scaled and oriented to the global co-ordinates. This would mean that if the object moved in an animation the material will stay still.
  • Object
    • With this type you can attach the material co-ordinates to another object such as an Empty. The other object must be named and of course exist. This is incredibly useful as you can animate that other object to move, scale, and rotate, the material.
  • Orco
    • The default mapping method to the object material co-ordinates. If the object moves the material will move with it. In most circumstances this default works just fine. It is possible to translate the Orco co-ordinates in scale and position.
  • Win(dow)
    • The texture is mapped as though being projected from the camera. Therefore if the camera moves so does the texture.
  • Stress
    • This is a brand new Map Input type and basically allows a texture to alter based on stress of the mesh. That means if the mesh is stretched from its default state a material or texture attribute can be made to change also. Here is a link from Blender v2.42 release log. Potentially this could have some interesting uses beyond the rubber example shown. http://www.blender.org/cms/Material_Features.764.0.html
  • Tangent
    • Another new and interesting map input type for creating the look of brushed metals. However, the current Blender release, 2.42 only allows this type with UV mapping. Therefore it’s beyond the scope of this training material.

There are other exotic mapping methods which, although useful, are not usually necessary with the majority of texture needs. However, if you would like to explore them read the Blender Wiki pages:- http://mediawiki.blender.org/index.php/Manual/PartIV/Map_Input

[edit] Back to the coffee stain texture

These are the settings that I found were best for the coffee stain.

Image: BSoD-Materials-Textures-image-tex4.jpg

[edit] Size

  • Set sizeX, sizeY, and sizeZ to 6.20

[edit] Position (offset)

  • Set ofsX to -2.300
  • ofsY to 1.200
  • ofsZ to 0.000

[edit] Previewing to Help

A really neat trick, to help you with this repositioning, is to set a preview SHIFTP in the top viewport.

Any of the editing windows can be set to the top viewport by pressing NumPad 7. As you update the scale and offset values in the Map Input tab you will see the preview update.

Other View Controls

NumPad 1 - Front View
NumPad 2 - Rotate View Down
NumPad 3 - Side View
NumPad 4 - Rotate View Left
NumPad 5 - Ortho/Persp
NumPad 6 - Rotate View Right
NumPad 7 - Top View
NumPad 8 - Rotate View Up


If you were to render the scene now you would see a rather disappointing coffee stain that only appears in the wood grain. Why is that?


When we started creating the textures for our desktop we set some Warp and Stencil effects on previous texture layers. These will affect all textures that follow them.

The Warp effect can be turned off on a subsequent texture layer but Stencil cannot. That means to get an undistorted coffee stain it really should have been the first texture.

[edit] Re-ordering textures

Fortunately Blender has tools to help with this process.

[edit] Buffer

You may have wondered what those up and down arrows were in the Texture tab of Materials button. These give you access to a temporary storage area called the buffer.

You are able to copy a selected texture to this buffer then paste it into another texture slot.


All material settings, like Map Input and Map To, are copied with the texture. It is therefore a very useful tool.

[edit] Exercise

Your turn to try this out on your own. I want you to copy the other textures down by one slot, then copy the coffee-stain texture up to the 1st texture slot.

You should end up with this.


You will notice that the coffee-stain texture shows that there are 2 copies in this material. Don’t worry about that for the moment because we can use the other copy for a nice special effect. However,  LMB Image:Template-LMB.png the arrow by the second coffee-stain texture to temporally turn it off while we set the Map To settings for the first.


[edit] Setting the Map To Options for the 1st Coffee Stain Texture

With the first texture slot selected in the Materials Button select the Map To tab so that we can set the way this texture will be combined with the material color.


If you were to render now the effect wouldn’t be quite right. Here I have just rendered a portion of the screen centred on the coffee stain.


The Mix blend mode has mixed both the Black background, of the image, as well as the stain mark itself. We need to get rid of the black background. Once again Blender has the ability to do this.

  • Switch to the Texture Button F6 and in the Image tab select CalcAlpha and UseAlpha. This will make the black area of the image transparent.


NOTE:
Alpha, in materials, is quite complex. Here we are not using any alpha to make the material itself transparent. However, there are examples in later files that use material alpha.


  • Switch back to the Material Button. I am sure you don’t need to be reminded of how to do that. (HINT: - F5 no more hints.)
  • F12 to re-render.


Quite a subtle effect but the stain has slightly bleached the surface and because the coffee contained far too much sugar the specular and reflective difference between the normal table and the stain can be seen.

[edit] Adding some magic







Redirects to fix

  • BSoD/Introduction to Materials/part1i → Doc:Tutorials/Materials/BSoD/part1i
  • BSoD/Introduction to Materials/part1k → Doc:Tutorials/Materials/BSoD/part1k

Contents