Sculpted Prims IV

abstract:The tutorial gives an insight into the texturing tools of blender. We show the secrets of ambient occlusion, how to bake highlights, how to set up the blender light system, how to use the node editor and how to create and apply bump maps.
The tutorial works for Blender 2.49b and Jass2.

Here is the next tutorial from our series about sculpted prims with blender. This time we will take a closer look into texturing. Our main goal will be to let the top-hat look much more glamorous. So far we have created a very basic material for our hat. We have baked the texture and got an almost completely black image with a red area for the hat-band. We will proceed from here, by introducing a few new texturing techniques.

In particular:

we add ambient occlusion to the object.

We will take a brief look into the blender light system,

and eventually we will add light-dependent shadows

and colored light effects.

We will see how we can add a shiny effect into the textures.

And at the end we will see how we can improve the look and feel even more, by creating and adding bump-maps to our textures.

Part I: Ambient Occlusion

Ambient occlusion describes the illumination of your scene with only diffuse light. Since diffuse light is independent from the angle of incidence, the AO-calculation is independent from the camera position and independent from your light setup. The only variation on the object lighting is produced by occlusion either from near-by objects or from self-occlusion as demonstrated here.

With decreasing aperture-angle, the edge between the two surfaces gets less and less ambient light hence it renders darker and darker. Although ambient occlusion is an artificial calculation, it helps us to make an object look more realistic and since it is not depending on the camera position, it can safely be baked into a texture.

Now let us see, how we can use ambient occlusion on our hat. Unfortunately the hat is totally black at the moment, and thus the whole effect of ambient occlusion will be mostly invisible. So let us change the hat color to white for now, and switch back to black later.

Select the hat body and go to edit mode.

Ensure that you are in the edit button section

Select the black material using the material index selector.

Click on the black color area and change the color to white. the hat will become gray.

In the following sequence we will add some slight modifications on the model to optimise the texture baking. It is always a good idea to keep your model as it is, and work on a copy of it.

So let us go back to object mode and select the hat,

then shift-select the tie and the bow.

Now copy the selection by pressing: shift D,

and immediately click the-left mouse-button.

Now we have 2 separate objects precisely intersecting-each-other. We will move one of the objects to another layer and keep this copy as our reference model.

Press the M-key. A small layer selector box opens.

Choose layer 6.

Now you have one copy of your object on layer 6 and another copy on layer one. Go to layer-one, and select the object there.

Ensure that you also have selected the UV-Tex map which was introduced in the previous tutorial. We will use this map for the proceeding work.

go to edit mode and select all vertices of the hat.

In the UV image editor create a new image.

Be gracious, and make this image large. For our purpose a size of 1024 pixels in each dimension is sufficient. However you may want to use an even higher value when your object has got many fine de-tails.

rename your image to “AO-map”.

Switch to the shading tab, and there select the world buttons.

Locate the Ambient Occlusion-button, and enable it.

Keep everything to the defaults, and just bake the ambient occlusion map by navigating to:

render, bake render meshes, ambient occlusion. It may take a few secs to generate the map.

Let us take a closer look at the map. If you see black triangles ,this is most probably because we have introduced a pole at the top of the hat.
We will correct this in a moment. If you look close to the map, you see that the neighbour objects do have an influence on the amount of darkness. This is so, because the ambient light gets occluded by near-by objects. Here in particular by the bow and the tie. You also can clearly see the border of the brim. But the whole image looks a bit grainy. For a good ambient occlusion map, we will want to correct this too.

So let us first take care of the triangles.

go to edit mode

switch to the edit button section

Locate the pole, and select its vertices.

You can look at the top menu-bar to see how many vertices edges and faces you currently have selected. There should be eight vertices in the current selection.

Then switch to the edit buttons, and click the smooth button once.

You have now introduced a hole at the top of the hat. But don’t care about that. We will close it again later.

Now go back to the Shading section and within the world-buttons locate the ambient occlusion tab again.

change the number of samples to 20. This number will determine the degree of smoothness of your map. But it will also make the map calculation take much longer. Don’t fear, you only need to do this once at least as long as you do not change your model any more.

Now bake ambient occlusion again. Go for a cup of coffee in the mean time.

Later you might decide to make the map even bigger or use even more samples. For now, our occlusion map is good enough. It is a good idea to store your image on disk now. Otherwise you will have to recreate the map later and you probably do not want to do that often because it is a time consuming task.
Well, now we have baked the ambient occlusion into an AO-map. We can take this map, reduce it to a reasonable size of let us say 512 by 512 ,
and use the result as texture for our hat in OpenSim or any compatible online world of your choice. Then we can use the viewer’s color picker to colorise the hat and we are done. But what if we wanted back the red color band? It is not included in the AO map?

So let us see, how we can bake the texture and the AO map all together:

go to edit mode

and select all vertices.

now change to your hat texture.

You possibly may want to create a new image now with a reasonable size. 512 by 512 pixels should be ok.

and finally Bake the texture only.

Ok, we somehow expected this to happen. when enabling draw type textured a totally white hat with a red band is what we get. See how different the model looks now ? All three-dimensional information is almost gone. Switch forward and backward between the AO-map and the texture. See how nicely the model’s 3 dimensional characteristics get supported with the ambient occlusion map ? Now wouldn’t it be nice to have both ? in the texture ? The color and the ambient occlusion ? Here is the trick:

check that you are in edit mode, and all vertices are selected.

also check that you have the hat-body texture selected in the image editor.

Then go to the shading section,

select the material buttons.

Now locate the texture stack, and add a new texture to it.

Name it AO-texture.

go to the texture buttons and select the texture type (image).

From the upcoming selector box select the AO-map.

By now we have added the AO-map to the texture stack and it is again time to render, bake render meshes, texture only.

So this is not what we expected. What is missing here ? The ambient occlusion was generated by using the sculpties UV-map. This was automatically and silently done, when we baked the AO-map. And this was a good decision because you just can use the AO-map on your sculptie without modifications. But now we apply this texture as an image. So blender needs to know how to wrap it correctly around your model. And this is done as follows:

Go to the material buttons,

Select the AO texture (if it is not yet selected).

switch to the map input tab,

enable the UV-button, and specify which UV-map shall be used for baking. Of course it is the same map which we implicitly used before when we baked the AO-map namely “UV-Tex”.

Now bake texture only again.

And the result is your base material texture plus the ambient occlusion map, both smoothely merged. But wait, we are not yet done! The red color band does not show any ambient occlusion yet. Why is this so ? Well, until now you have only applied the AO-map to your black material. And the hat-band-material does not see it yet. So Let us correct this now :

go to the edit-section.

now select the hat-band-material by using the material index selector.

go to the material buttons,

From the texture-selection box select the already existing AO-texture. By doing this the previously created ambient-occlusion texture gets reused for the hat-band. But we still need to switch to the map input tab and …

Enable the UV-button, and tell blender again to use the UV-Tex map.

And finally do another render, bake render meshes, texture only.

And the frustration is big, The hat-band is gone again. Why that? Well, we have fallen into a trap. Something slipped through our attention. Let us go back to the Shading buttons and check the Map-too section of the material. We see that the blend type is set to mix. So what gets mixed here ? Everything on the stack above the current texture will be mixed with the current texture. But since there is nothing above the current texture in the stack the base material settings are taken instead. The amount of mixing is defined by the value of the color variable. Currently this value is set to 1, and thus the current texture on the stack completely replaces what was there before.

So neither the hat-band, nor the white hat body is rendered. And only the AO-map is seen at the moment. We have several options to proceed from here. The simple solution is to change the mix-value to 0.5 which would do what the name implies. It mixes the base material and the Ambient-occlusion-map, both with an amount of 50 percent. But this option creates washed-out textures.

An enhancement could be to use blend mode “overlay” for the hat-band. And set the color-value to 1. This will result in a much crisper color definition, and still contain the ambient occlusion.

Another and probably the best option would be to use the Ambient-occlusion-map as multiplier on the hat band. So it does only affect the light-intensity of the texture. You will need to play with the color-value until you get a convenient result. Finally let us make the material black again:

go to the edit button section

switch to the hat-base material

and make the hat-base black.

In the Map-too-setting of the hat body set the color value to 0.5.

This will eventually result in a dark grey hat with still visible ambient occlusion.

So far we have created a texture which contains our basic material settings namely the black hat-body and the hat-band. We have added ambient occlusion by justusing the AO-map as a texture on the texture stack. And Now we want to add some extra lights. And bake those lights into the texture.

Light setup

So let us first check what we can see right now with blender’s default light setting. Do this by clicking on: Render, bake render meshes, full render.
Ok, this is disappointing. We obviously will have to add some lights. Please note that normally we will setup light in such a way that all objects look nice from the camera location. You would not necessarily take care about parts of your object which point away from the camera. But for baking textures this is no longer exactly true. You will want the object to be illuminated in a different way. Here is one possible way to go:

We will use 4 lights in total. While proceeding, we want to get a rough idea about how the lighting will influence our texture. We can use the draw type (shaded) here. This mode simulates the light effects in real time. But take care here. If your computer is not fast or if your model contains many faces or you got many lights in your scene shading mode can start to consume lots of your computer resources. So if your blender is freezing you have to reduce either of the before mentioned settings.

With your draw type set to shaded, go to the shading section.

there, switch to the lamp buttons.

go to top view. This will help you to find good locations.

Finally add a new hemi-light by clicking on add, lamp, hemi.

Place this light besides the camera, and slightly above the hat and rotate it so, that it points towards the hat. You will switch the view-point between top, front and side-view for this adjustment.

Now reduce the Dist value such that the pink line is as-long-as the distance between the lamp and the model.

go to top view and add 2 more hemi-lights at an angle of plus 120 degrees, and -120 degrees, both relative to the first lamp.

Here is a quick way to get this done:

place the 3D-cursor on top of the hat.

Set the 3D-cursor as Pivot.

Select the Hemi-light and make a copy of it by pressing: SHIFT-D,

Immediately followed by a left mouse-click.

press the r-key, and enter 120 on the key-board.

Make yet another copy of the just created light and rotate it again by 120 degrees.

Finally add a fourth light, which will iluminate the hat straight from the top.

Now set draw type to texture, to see what you will bake.

Then select the hat and start another full bake to see what changed.

Ok, still not too much of enhancements. The model still looks very artificial. What really is missing here, is an interesting structure of the material. And we can do a lot with texturing here. But before we do this, let us first add a bit of shiny-ness and con-tour to the hat.

Baking Specularity

Go back to draw type solid. you now see some specular reflections on the hat. These reflections are fully dependent on the camera view-point. On the other hand we can only add static information to the texture which is independent of the camera view-point. But we can use a trick here. We will create a node based material
and use the specularity information to modify the texture. But beware, the trick may not always create the expected results. You will need-to-do some experiments to figure out how you must set the light to get the reflections where you want them to be. If used carefully this trick can add interesting effects to your final result. But at the end allways remember that this is a fake reflection which probably interferes with the rendering engine of your online world.

Anyways let us try this out now. If you don’t get it at the first time, then try it again and again. It is by far simpler as it appears to be. So here we go:

ensure that you have selected the black hat body material,

go to the shading section,

locate the link and pipeline tab, and there enable Nodes.

Now this material is node based and you can modify it by using the node editor.

So let us split the screen and open the node editor.

You see two boxes. The left box is the material node. The other box is an output monitor which displays the resulting material.
Now we will replace the material node by an extended material. We do that because the simple material does not have a specularity channel while the enhanced material has got one.

So remove the material node by first selecting it,

and then press “x”, or the delete-key.

And add an extended material from the add, input, section.

Now add a mixer by pressing the space bar, then add, color, mix. We need the mixer to mix specularity information and color information.

You see that the mixer node has allready been connected to the material node. We will change the connection slightly by moving the defuse connector to the specularity connector. Actually we simply click on the specularity connection then drag to the secnd color-input of the mixer node, then release the mouse. The connection has now been changed.

We connect the mixer to the out-node by clicking on the color output of the mixer,

then drag the mouse to the color input of the out-node,

and finally release the mouse.

Now the nodes have been setup but the material node still-must-be connected to an existing material. Go to the material-node and there select the black material from the selection box. Now the node based material is ready to go. Finally render, bake render meshes, full bake again and see your results. Ensure that you are in Draw type texture to see the results of your bake.

Now we get some-where. There is still much room for improvement but now the look of the hat has become much more interesting. So with applying specularity the hat gets much more contour.

Lets do yet another enhancement. Look at the top-edge of the hat body. There you see a specular effect but it is not very well defined. The reason is that the model is using a low poly mesh but the texture should be created with a much finer mesh and then “baked to the low poly mesh”. We will come to this technique later. For now we can just increase the number of subsurf levels by one or two, and then full bake again.

Go to the edit section.

locate the modifier stack.

increase the number of render-levels by 2.

And now bake. This will already give you a significant improvement.

After baking all the fine details are visible in the texture and so you can get very fine details without increasing the mesh face count by just baking them into the texture, and using this texture on your low poly model. Now play around with the lights and see how your specular effect changes with the light settings.

For example you could get a bit adventurous and colorise your lights. Check that you are in draw type “shaded” to monitor your changes in real time. Also take care that the sum of all lights mixes more or less to white. As an example use one light with red, the secnd with green and the third with blue.
And effectively “paint” on your hat with your light sources. Check the results by going to draw type textured and start another full bake.

And now it is time to examine the texture stack and add more structure to your surface. A realistic top hat will be made out of felt or a comparable material. So let us try to get such a texture for our hat now. We will try a procedural texture here.

select the black material in the edit button section,

Then go to the shading-button section,

and there switch to the texture stack, create a new texture, and Name it “felt”.

switch to the texture buttons, and select texture type (woro-noi)

Now make a full bake to see what happens. ok, this is yet another surprise. Why the hat has become dark-pink with black spots on it ?

Now…Why is this hat pink ? For some reason the developers of blender have choosen to use pink as the default color for any texture. We will change this in a moment. But let us remember what we wanted to achieve in first place. The hat should look like made out of felt. So also the size of the dark spots seems wrong and we want to get a much finer result.

Now lets go:

locate the noise size setting in the texture button section.

change the value to 0.02 or any other value to your taste.

switch to the material button section.

in the map-too tab change the secndary color from pink to white.

Then bake again.

The spot size is still much too big. So let us change that in the map-input section.

change the size settings from 1 to 40 in all dimensions.

Then bake again.

Now the hat is almost like we want it but it has become light grey. This was because we have choosen the secndary texture color to white. We could have used grey instead, and thus keep the hat darker. But we will do another much better trick:

go to the map-too section,

there disable color and enable “nor”. This means the texture no longer changes the color of your model but now affects the normals.

The amount of the effect can be set with the Nor-value which we will set to around 1.5.

Now bake again and see.

ok, try to reduce the specu-larity, Felt is not shiny.

And bake again.

So by using a noise-texture as normal map we created a material resembling felt. We still can find improvements, and there may even be much better approaches. If you know an interesting approach feel free to tell it to us.

Bump Maps

Now let us turn back to the red-color-band. It still looks like it was painted on the hat. We will now try to let it appear as if it has been wrapped around the hat. Of course we could model this detail easily into the mesh itself. But i will demonstrate instead how we can add higher resolution details to a low poly mesh by using a bump-map. But before we get practical i will give you a brief idea about what is going on behind the curtain:

Please remember, that this hat has been created with 8 faces in x, and 8 faces in y. Hence in blender it is made out of only 64 faces. But in world we count 32 times 32 faces hence we see 1024 faces there. All these extra faces have been calculated by means of a subsurf-modifier. Then they have been converted into the final sculptie-map during the sculptie-baking process.

In order to see what happens we will tell blender now to show us these extra faces right on the model. But instead of using the original model, we will create yet another copy and work on the copy instead.

go to object mode

Ensure, that the hat is selected.

Also select the lights. We will need them in a few secs.

then press SHIFT-D, and immediately click the left mouse button.

Press the M-key, and move the copy to layer 5.

Now we have copied our model plus our light setup to layer 5. Switch to layer 5, and select the hat-body.

go to the edit button section, and locate the modifier stack.

You will find one subsurf modifier there. Ensure that the number of levels is set to 2.

Then click the modifier’s apply-button.

and finally switch to edit mode.

What you see now is almost identical to what will later be imported to OpenSim (or your preferred online world). The model is now made out of 32 times 32 faces. So there is not much more room for finer detailed modelling. But let us make an experiment. Let us add another subsurf modifie and add 3 more levels of subdivision, and then apply the modifier.
Now we do have a very high poly model, which contains more than 64 thousand faces. Indeed i have choosen the numbers such that we coulduse a texture of size 256 times 256 and end up with exactly one image pixel per model face.

Now let us apply a bit of noise to the high-poly model. We enable the proportional edit tool, and select the random fall-off. Then we select just one vertex, and scale up or down while we increase the edit range more and more. Once the hat looks like a hedge hog, we stop and full bake, what we have right now. Now the texture contains the light effects of the noisy surface.

Now switch to layer one and see how the same texture looks on the low poly hat. So the low poly hat looks similar to the high poly model, at least up to a certain extent. You see, that you can at least in principle use the texture to add some fine details to your object without actually adding more vertices and faces to your mesh.

But we also can turn the whole process head over heels. Instead of using the high poly model as our source and bake the results to a texture we also could use a special, typically a black and white texture where the color value of each pixel of the texture defines a certain displacement of the surface along the face normal of the corresponding location.

Blender introduces bump-maps,normal-maps,and displacement-maps.

bump-maps can be used to simulate what we just have shown with our high-poly model. Blender will create a virtual mesh point for each pixel of the bump map, and raises or lowers this virtual meshpoint along its vertex-normal depending on the pixel’s color. As a result a bump-map simulates a surface with much richer detail then the actual mesh supports. So Bump maps can enhance low-poly meshes and let them appear much more structured as they actually are.

Normal-maps are very similar to bump-map but instead of a grey scale image they use an RGB-image for the vertex dispositions. Hence Normal-maps can be used to move the virtual mesh points in an arbitrary way . So we can say, that bump-maps are a special case of normal-maps where the modification only takes place along the vertex normals.

Displacement-maps directly modify the mesh during bake time. And in contradiction to bump-maps this map type can-not add fine details into the texture. The amount of displacement is again directly coupled to the grey-scale value of corresponding pixels in the map. Black will displace a vertex in-wards along its vertex-normal while white will displace the vertex outwards.

So the effect of displacement-maps can always also be achieved by directly modelling the mesh itself. Displacement maps are of less concern when dealing with texture baking. But nevertheless i will show you a nice example where we can use them for our purpose. Note that your model is not modified at all. Only during baking the baker will apply the displacement map calculate the texture map due to the modified mesh and either renders the result to the render window or (as in our case) to the baked texture.

So in short the bump-map adds virtual bumps and wrinkles to your mesh with the bump direction always along the vertex normals. The resolution is directly proportional to the texture size of the bump-map. The normal-map is like a bump-map but allows arbitrary bump-directions. The displacement map directly manipulates the mesh-vertex points and thus does not add more details.

We already used bump-maps when we created the felt-surface-texture. There we have configured blender to use a noise-texture as a Normal-map.and by means of this we simulated a high poly surface.

So, now we are ready to take care of the hat-band. We will create a texture, which is completely white at the locations which correspond to the hat-band. And completely black elsewhere. This map will simulate a small raise of the band above the hat. We create this texture as follows:

remove the high-poly hat from layer 5. We do no longer need it.

select the hat on layer 1,

make a copy of the hat-base and place this copy on layer 5

Select the hat on layer 5, and go to edit mode.

switch to the red hat-band material.

Switch to the shading button section.

create a new material named white-hat-band and make it white.

disable the Nodes button and disable all textures on the texture stack.

in edit mode verify that the hat-band vertices are now assigned to the new material.

switch over to the black material.

Again go to the shading button section, create a new material, disable the Nodes button and disable all textures in the texture stack.

Now select all vertices, and in the image editor,

create a new image of size 1024 times 1024. Name it band-bump-map.

then render, bake render meshes, texture only.

Now we have constructed the bump-map. we only need to apply the map to the hat now:

switch back to object mode, and then select layer one.

Select the hat

then select the hat-band material

and switch to the shading-buttons section.

There, add a new texture and name it band-bump-map.

go to the texture settings.

there, set texture type: image.

And load the band-bump-map.

now switch to the shade buttons.

in the Map-input tab, enable UV, and specify “UV-Tex”.

in the map-too section, disable color, and enable Normals.

Use a value of about 20 for nor.

Now you can render, bake render meshes, full render. The effect is not very prominent, but it works. However we can get a bit advantereous, and try to use this map as displacement map. Remember, that the baker will first apply the modifier stack before baking. Hence we actually have 32 times 32 faces available for the displacement.

So reduce the nor-value to something below 2,

and enable the disp-button in the map-too settings.

Set the displacement value to something about 0.15

then full bake yet another time.

And at the end the hat band looks like it actualy was modelled in 3D. And this is what we wanted to achieve. Let us add some horizontal stripes to the band.

in the edit-section, ensure that you have the red hat-band-material selected.

in the shading section add another texture. Name it silk.

go to the texture section, set the texture type to: clouds.

go back to the shading section, then in the map-input-tab, set all values to Y in the coordinate map.

Also enable UV and set UV-Tex as the map.

finally set the y-size to 10. This setting will create horizontal stripes.

In the map-too-section, disable color and enable normals.

use a value of 5 for nor.

Now render, bake render meshes, full bake.

Mischief accomplished. The final texture of this tutorial is ready for import to your online world.

From here you can take a long time to experiment and improve. I have not shown all available texturing-options in blender. I just scratched the surface.

In particular,

we have created an ambient-occlusion map for the object.

We have taken a brief look into the blender light system,

and we added light-dependent shadows

and colored light effects.

We found a way to bake a specular-reflection effect.

And at the end we have improved the look and feel even more by creating and adding bump-maps to our textures.

You can find hundreds of good texturing tutorials in the internet. And once you have mastered the basics of this tutorial you should be able to follow those other tutorials without problems.

And now enjoy texturing. and have fun.
see you later!

Extra hints

If suddenly the baked textures do no longer show up in the 3D viewer, then you have become the victim of a blender bug which happens occasionally.
Here is what happens: Sometimes when you are in texture mode you do not see any effect on your model directly after you baked your texture.
And here is a way how you can get around this problem if it happens to you:

go to edit mode

in the UV image editor enable paint mode,

and click once on the texture. Now you have added a color spot on the texture and as a side effect the entire texture will also be visible on the model.

use control-z to revert the just created small spot in the image.

This is annoying, but it helps at least to get further.
An even better alternative to handle this problem is to save your work into a .blend file (File -> save) then stop blender and restart it, and reopen the just saved blend-file. The problem will also be gone.