Found something useful on KatsBits? Support the site and help keep content free
Or click here to learn more about this important message »

Learning Blender 3D - ambient occlusion & vertex painting

Learn to make a Simple Sword in Blender

Aside from using the functions and processes we've been discussing throughout this "make a simple sword" tutorial, there are couple of additional features available to the artist that often prove useful for graphically enhancing models in one way or another. Two of these are "Ambient Occlusion" and "Vertex Painting". Both essentially allow the artist to modify a model in a way that, in combination with traditional texturing, helps improve its appearance with relatively little effort.

Ambient Occlusion ^

Ambient Occlusion is a form of indirect 'global' illumination that's different to normal lighting in that it isn't specifically directional in nature. It does not cast 'shadows' but it does 'shade' objects. This shading is determined by surface proximity, i.e. the distance between surfaces directly influences how well each surface is illuminated - obscured surfaces receive very little light, unobscured surfaces receive most. In practice ambient occlusion is a useful graphical enhancement for 3D models because the shading it produces typically emphasises the three dimensionality of an object without resorting to the use of obvious and often harsher shadowing.

To make an ambient occlusion map for our sword model we need to use Blenders "Texture Bake" rendering sub-system. Click the "Camera" icon in the "Properties" header to access Blenders main "Render" settings. Scroll down to the very bottom of the list and click the arrow to the left of "Bake", this opens the various options needed to bake textures.

Texture Bake option in "Render" properties

Click "Render" properties to access "Bake" options down at the very bottom of the panel (scroll down - click the arrow to expand)

Next, in the "Bake Mode:" section, select "Ambient Occlusion" from the drop-down list - "Bake Mode: Ambient Occlusion", and make sure to set "Normalized" and "Clear". Leave the rest 'as is' using their default settings then click the "Bake" button to render the ambient occlusion map. Once done the view in both the main 3D window and the UV/Image Editor will change to show the baked ambient occlusion map - a grey-scale image representing the shading the process has determined appropriate for the object. This needs to be saved.

Select "Ambient Occlusion" from the list of Bake options

Select "Ambient Occlusion" from the list of options and set "Normalized" and "Clear", leave other settings as they are (defaults)

Click the "Bake" button to render bake an AO map

Click the "Bake" button to run the ambient occlusion render baking process, the model in the 3D viewport and UV/Image Editor will display an updated grey-scale texture showing various degrees of shading

In the "UV/Image Editor" click the "Image" menu option - it will appear as "Image*", the "*" indicating unsaved data - and select "Save As". This opens the "File Browser".

Save the ambient occlusion map as an image

Save the results from the "Image*" menu - the "*" indicates an unsaved datablock

In the "File Browser" we need to do a couple of things. First, if necessary change the file name[3]. Second, browse to a location to save the file. Third, in the "Save As" sub-section bottom-right select the image format, "Targa Raw" in this instance. Select also "Relative Path"[1] and "Copy"[2] if you don't want to save over the data currently in the scene. Then finally click the "Save As" button[4] top-right to save the file.

When saving the AO bake make sure to save as a Copy so original file isn't overwritten

In the "File Browser" select the format from "Save As" and ideally (but optional) select "Relative Path"[1] and "Copy"[2] - Copy is useful for saving a 'copy of' the texture instead of over-writing the current material image

With the image now saved, open it into a photo editing package and layer it over the texture used previously - as it's not within the scope of this tutorial to discuss the complexities of photo-editing simply use a "Merge Mode", "Soft Light" for instance, to blend the Ambient Occlusion map over the top of the texture. This should produce a final image with some degree of shading present. Save the file as a TGA or other image format Blender can read/open (*.bmp, *.jpg, *.tif).

Combining AO map in photo editor to produce better textures

A simply "Soft-Light" overlay of the ambient Occlusion map on top of the original block coloured diffuse image provides an image with a bit more depth. Save to or over image previously used to texture the mesh

Back in Blender click the "Texture" button to see the properties previously assigned to the Material. Scroll down to "Image" and click the "Reload" button[1], if both Blender and the photo-editing application were open at the same time, the updated texture will then appear. Alternatively, the updated image should be in place the next time Blender is opened as the texture will be reloaded automatically as part of the default asset loading process. Either way the result will be something similar to the image below, the final texture now displaying varying degrees of 'shading'.

Reloading updated Diffuse texture bake into Blender

Reloading[1] the image into the texture slot will have it automatically update and display in the 3D View and UN/Image Editor

Vertex Painting a mesh ^

Another simple mesh enhancement is "Vertex Painting" where, as the name suggests, individual mesh vertices can be 'painted' with a colour, usually an "RGB" (Red/Green/Blue) or "black/white" value that relates to the 'saturation' of each, from 'no colour' (white) to 'full colour'/'black' ("0.000" to "1.000"). Generally speaking vertex colouring is not usually 'baked' to an image unlike ambient occlusion, it's far more useful applied as 'mesh data' (information stored in the mesh).

To paint the sword, in "Object" mode RMB select the object then press either "V" or select "Vertex Paint" from the "Editor Type" drop-down menu in the "3D View" header, a new set of tools and options become available and the mouse cursor changes to included a circle, this is the 'brush' limit.

For the purposes of what we're doing here we only need to pay particular attention to the colour wheel and tonal slider (shown below); "Radius: 35", which is a default setting, changes the size of the brush - the circle bordering the mouse cursor; and "Strength: 0.500", also a default setting, affects the intensity of the effect when applied. Although we can change the size of the brush, the latter, 'strength' is more appropriately managed through the correct application of tonal colour.

Press "V" to enable "Vertex Painting" in Blender

Select "Vertex Paint" from the header menu or press "V" to enable vertex painting mode. The editing tools panel will change to show a new array of options, and the cursor will display with a circular limits marker

Painting colours can be done whilst in "Textured" or "Solid" mode; the advantage of the former means being able to see how the colours influence the final appearance of the model; the latter means we're able to clearly see the colours being painted onto the mesh as it defaults to a uniform 'white'. We'll switch to "Solid" mode so press "Z" (may need to be pressed twice) or select "Solid" from the "Viewport Shading" menu (shown below), the mesh will turn 'white'. As this will likely make it difficult to determine where individual vertices are for painting, turn on "Wire" from the "Display" options of "Object" properties (shown below).

Show painted and unpainted vertices, the mesh defaults to 'white'

Because colour is painted to vertices, enabling "Wire" mode[1] is helpful as a way to identify the locations of vertices in a mesh, especially when working in "Solid"[2] view which makes the entire mesh display 'white'

With the model ready, select a colour to paint by LMB clicking anywhere in the colour wheel/slider and/or LMB+hold+drag the mouse around, the resulting colour will display in the sample window directly below; this is what's painted to the mesh. (Release the LMB to set the colour if dragging to select). To paint the now selected colour onto the mesh simply LMB click a vertex, or LMB+hold+drag to paint over several vertices.

Design note: whilst painting, a scene can be navigated in the same way as normal. Use MMB +Shift/Ctrl to paint anywhere on the mesh by rotating, moving and/or zooming the scene. Using 'zoom' also allows the painting of large sections of the mesh or individual vertices due to the way the cursor/paint brush stays relative to the screen in size. If a mistake is made reset the colour wheel/slider to 'white' and repaint the vertex/vertices, or use "Ctrl+Z" to "Undo".

Using tone and colour to effect the intensity painted to the mesh

Both the colour wheel and the slider perform the same task in that they mix 'tones' and/or 'colours' to varying degrees of "saturation", that is from 'white' (no colour) to 100% full colour ('red' for example), or from 'white' to 100% 'black'. Colour intensity when painted to the mesh is best served 'mixing' colours/tones towards 'black' or 'white'

Full intensity colour fully saturates a vertex

Sliding the 'tone' all the way to the bottom means painting 100% black on selected vertices, overriding and colour tinting that may have been selected originally - mesh paint defaults to 'white' or 'no colour'

Once the mesh has been painted press "V" to exit "Vertex Paint" mode and then "Alt+Z" to switch back into "Textured" mode so we can see how painting vertices effects the appearance of the final mesh and texture, to subtle or not-so-subtle affect (see below).

Sword mesh painted blue and green to show the effect on the textures appearance

Using vertex colours a mesh can be painted and the overlying diffuse texture changed, in this instance from 'yellow' to 'blue' without necessarily touching the texture image itself

A more typical use of vertex colours that 'shade' the mesh

A more typical use of vertex colours is to add a bit of shading to a model to give it a bit more depth than otherwise might be had [see *.blend "33"]

Conclusion ^

This concludes the tutorial. Much of what we discussed can be applied to any manner of object so long as some forethought is given to the task at hand. This is a important aspect of making and creating content if we can analyse and have a basic plan in mind before we start work, it makes the actual production process less confusing because we already have a general idea of the direction we need to be going in, aided of course by the presence of the reference material throughout. Remember this when embarking on any future 3D projects.

KatsBits Web
Search KatsBits using StartPage
Hottest item in Store right now!
Hot Product in Store
Visit the Store Now
  • Blender Art Magazine
^