Bake Tiling (tileable) Normal maps from meshes in Blender

Bake tiling normal maps from meshes in Blender

There are generally two types of normal map usage in games; 'unique', 'single use' textures made for specific items; and 'tileable' textures created to cover generic content or larger expanses of the game world. In either case Normal maps can be made using high-resolution, highly detailed meshes. However, when doing so using Blenders "Texture Bake" feature, the techniques used, and various aspects of the process, differ slightly.

The following discussed the use of Blenders "Texture Bake" rendering sub-system to generate flat tileable (tiling) Normal maps from high-resolution mesh objects, in this instance a sculpted rock texture.

Design note: the considerations discussed below apply generally to all types of tiling content where mesh-baked normal maps need to repeat across a surface. They are not reserved exclusively for rock, as exampled in the following material.

Familiarity with Blender is preferable but not specifically required. For more information on using Blender read the "Make a simple Chair" tutorial that walks the user through the application whilst making a simple furniture item.

Design note: for a more general information on baking Normal maps read the "Bake Normal Maps from Meshes" and "Bake Normal Maps using Blender Cycles" tutorials.

Preface ^

There are a number of ways normal maps can be created using high resolution, detailed meshes in Blender. One utilises a special 'normalised' Material assignment subsequently rendered through a perpendicular camera arrangement, the other Blenders integral "Texture Bake" sub-system to 'bake' meshes. Although both do produce functional normal maps, the latter is more effective as its considerably less time-consuming, and more flexible, to set up and use, as well as being able to properly take into account the full "X", "Y" and "Z" coordinates and orientations of individual faces than top-down, single-axis rendering.

Design note: a top-down render doesn't specifically read the inherent structure of a mesh because the camera used to 'observe' the object is doing so along a single (usually "Z") axes. Although the mesh may be assigned a properly 'normalised' material, the mechanics of the process is more akin to converting grey-scale images because the structure is essentially interpreted similarly.

With this in mind the following walks through the general process of creating tiling Normal map textures using Blenders Texture Bake system, that is, baking a high-resolution detailed mesh to an image UV mapped to a corresponding low-resolution flat plain.

Using a top-down camera set up to render tiling normal maps

Rendering a tiling normal map from a high-resolution mesh using a 'top-down' camera approach, useful for smaller, simpler normal production of a specific size but fiddly to alter once set up

Using Blender integral 'Bake' sub-system

Using Blenders 'Bake' sub-system is more flexible and tends to produce better results for complicated structures as depth is properly registered due to the physicality of the mesh (actual depth is being calculated and rendered) rather than the visibility of a normalised Material colour (high-resolution mesh shown in 'Solid' mode for clarity)

The High-resolution mesh ^

The high-resolution mesh is the structure that's baked. It contains all the necessary detail that's representative of the 'object' after which its modelled, a rock face, a stone wall, a set or section of floor tiles and so on. Care should be taken to ensure it repeats/tiles fully from left to right, top to bottom, and that the critical area being baked matches the area defined by the low-resolution mesh. The mesh objects "Scale:" values should be set to "1.000" ("Ctrl+A") to avoid the bake system introducing interpretive distortions. It does not require Material assignments and does not need to be UV mapped or assigned any images (aside from those temporarily aiding the sculpt process). The objects Origin should exactly match that of the low-resolution mesh, i.e., both Origins for high-and low meshes should be in the same location/co-located.

Design note: the mesh may have a Material and/or be UV mapped with an image depending on whether it needs to match a preexisting asset, the image being a visual aid towards this. If it is, the assignment is ignored during Bake. With regards to the objects Origin, placement is important because Blender uses it to determine individual vertex positions relative to a fixed point, which is then further used to determine the position of both high and low resolution meshes in relation to each other during Bake. On fixing mesh scaling issues prior to baking; use "Ctrl+A" selecting "Rotation and Scale" (which include "Location" as part of the overall reset), "Scale:" values will then reset to "1.000" for each "X", "Y" and "Z" axes (cf. "View" properties, "N").

High-resolution mesh for normal map baking

The high-resolution mesh that's baked. It's typically a highly detailed representation of a surface or object and should be set up to tile left to right, top to bottom. The amount of detail present may vary depending on eventual normal map size and use. Nothing else is needed

The low-resolution mesh ^

The low-resolution mesh is essentially a 'template' object that holds the image to which the high-resolution is baked. For use as a tileable texture it must conform exactly to the dimensions of the eventual bitmap image represented by the mesh (the eventual diffuse texture). Using the "Power of Two rule" this would generally mean it being square, rectangular, or lozenge shaped (or some derivative thereof, technology dependent), for example be 512x512, 256x1024 units and so on (Blender Units). For this, in "View" properties, "N", check the "X" and "Y" values of "Dimensions:".

Design note: physical size in terms of pixels only matters relative to output, the final images that's baked - the image mapped to the UV defines this, not the size of the meshes used to produce the end result (norma maps). In other words, to increase the size of the normal map, the image mapped to the low-res mesh is changed in "Image" properties (where the image is generated), not the mesh.

The mesh also needs to be completely flat as the resulting normal map is to be used as a tileable texture, deviations can cause issues. It should also have a "Scale:" value of "1.000" for each "X", "Y" and "Z" axis (cf. "View" properties, "N"). It must also be UV mapped, with the "Coordinates:" in "Mapping" set to "UV" ("Texture" properties). And have a Material assigned with associated Texture and Image slots, the latter assigned a "Generated" image, which is subsequently mapped to the UV (applied directly to the UV in the UV/Image Editor). The objects Origin must be in exactly the same place as is the high-resolution mesh.

Design note: for the purposes of texture baking, the low-resolution mesh should be assigned a single Material, additional instances should be removed else the bake will likely break in to sections per material or image assignment. The Material will need a Texture and Image slots, the latter occupied, preferably, by "Generated" data, a "UV Grid" or "Color Grid", largely to avoid the "Circular Reference in Texture Stack" error. The low-resolution mesh itself is essentially a physical placeholder that defines an 'image space', an area into which the normalised data is baked. Its density, whether or not its sub-divided, has no bearing on the Bake process in this context (rendering a flat tileable normal map). The physical size of the mesh does not matter so much as it follows the aforementioned 'Power of Two' rule, but its "Scale:" should be set to "1.000" to avoid issues - this makes the mesh actual size.

Low resolution mesh for normal map baking

The low-resolution mesh[1] is a placeholder that's UV mapped[2] and assigned a Material with Texture and Image slots[3], the latter is best occupied with a "Generated" image[4] rather than a bitmap. In most instances the mesh will be a flat surface plain sized relative to the "Power of Two" rule, so 512x512, 256x1024 Blender units and so on

Scene set up for Baking ^

With both high and low resolution meshes prepared they should then be placed together so they occupy, as best as possible, the same position in the Scene. For surfaces with a significant degree of depth variation, the location of the high-resolution mesh can be 'averaged' relative to the low-resolution mesh - this may result in a degree of overlap or intersection between the two (see below with low-resolution mesh highlighted red for clarity). Their respective Origin points should occupy the same position however. Delete or move other objects, including Lamp or light emitting objects from the active Scene - the Scene only needs to contain the two meshes used for baking.

Design note: some degree of intersection between meshes is less of an issue than no intersection but greater surface disparity (distances between each). The rock face shown below for example could pose problems due the distance between high spots and the flat plain were the latter to be placed under the lowest point of the former (plain placed at the very lowest point of the sculpt). Positioning the low resolution mesh approximately at the mid point (as a general rule of thumb) means there's equal distance between the highest and lowest points of the high-resolution mesh so there is less likelihood of omissions being baked (areas of no detail). As Origin points need to be coincidental, the meshes may need to be positioned relative to each other in Edit Mode rather than Object Mode (at least without then requiring one or the others Origin being reset).

Scene set-up for baking flat tileable normal maps

Scene set-up in Blender for baking a flat, tileable normal map. Both high and low (highlighted red in "Solid" display mode for clarity) resolution meshes should occupy, approximately, the same position with their respective Origin points coincidental (visible at the 3D Widgets location)

Normal Map 'Bake' Settings ^

Once the Scene is set up, access "Render" Properties and scroll down to the "Bake" sub-section. Click the black arrow to the left of the heading expanding the options. First left-click the "Bake Mode:" drop-down menu and select "Normals" from the list. The panels options will update. Next set the "Normal Space:" to "Tangent" (typical for normal map generation) and click the "Selected to Active" checkbox activating the option. The remaining settings can be left as is.

Design note: forgetting to set "Selected to Active" typically results in a "nothing to bake to" error. For like-to-like baking "Selected to Active" is required.

Finally in the 3D View "Shift+RMB" select the high-resolution mesh first, then low-resolution plain, selection order is important, before then clicking the large "Bake" button at the top of the "Bake" sub-section in "Render" Properties. Blender will parse the Scene showing progress in the "Info" Header and the "UV/Image Editor" if available.

Design note: when baking normal maps the "Diffuse" colour of the Material assigned to the low-resolution mesh is ignored - there is no "Normalized" option as available for other types of bake, e.g., Ambient Occlusion. During bake if the UV/Image Editor is visible progress will be shown, the normal map will be incrementally drawn in the Editor, in addition to the "Info" Header progress bar, the view will periodically update until rendering is complete, which will also temporarily display on the mesh if "Texture" display mode is active.

Select "Normals" and set "Selected to Active in Bake settings

In the 3D View select the high-res then low-res mesh, then in "Render" Properties set the "Bake" options to; "Normals" as the "Bake Mode:"[1], "Tangent" as the "Normal Space:"[2] and check "Selected to Active"[3], before then clicking the "Bake" button...

The resulting baked Normal Map as mapped to the low-res mesh

... Blender will parse the Scene and render the high-resolution mesh as a normal map to the image UV mapped to the low-resolution mesh, the result visible in the "UV/Image Editor" if active

Save the baked normal map ^

Once Blender has baked the normal map it will be available in the UV/Image Editor. If the view is not visible, temporarily swap an available area using the "Current Editor Type..." selector or press "Shift+F10" with the cursor over an area. From there click the "Image*" Header menu option and select either "Save As Image" or "Save a Copy". In either instance the "File Browser" will open. Set the name if it needs to be changed[1], the location to which the image will be saved[2], then select a format in the "Save As Image" properties section bottom-left[3], e.g. "Targa RAW", before then clicking the "Save As Image" (or "Save a Copy") button top-right. Blender will save the baked normal map data to the selected file format and location before then returning to the previous screen.

Design note: when saving the file both "Save As Image" and "Save a Copy" write the rendered data to file in the selected (bitmap) format. However, the former will save and replace the current image slot associated with the Material, whereas the latter simply saves a 'copy' of the file allowing the active data to be retained (this will be lost when the *.blend file itself is saved and reopened - bake data is 'session' or temporary in nature). With regards to the format: when saving the normal map preference should be given to using 'raw' formats or those utilising 'lossless' compression to avoid compression or other pixel/visual artifacts - typically this might mean using "Targa RAW", "Bitmap", "Tiff" etc., avoid JPG as the compression algorithm tends to result in the appearance of artifacts in the normal map that degrade its quality/clarity.

Saving the baked image from the UV/Image Editor

Once the image is baked it will be available in the UV/Image Editor. To save click the "Image*" menu option in the Header ("*" indicates data not yet saved) and select "Save As Image" or "Save a Copy"...

Saving the baked image, setting the format and location

... which opens the "File Browser". Change the name if necessary[1]; the location to save the file[2]; select an image format, preferably a lossless compressed or raw ("Targa RAW" shown, "Bitmap" etc.); then click "Save..." top-right

Conclusion ^

Of the techniques used to create normal maps, converting images, camera render, or baking meshes, the latter is more advantageous specifically because it makes use of an actual three-dimensional structure instead of interpreting flat 2D tonal (grey-scale) values or a normalised flat plain, a difference that essentially equates to 'faux' versus 'actual' depth perception and interpretation - tonal variance, although a good approximation for surface detail, is not the same as the gradient variation of physical structure. So whilst the converted images et al provide a quick way to get workable results, they are better suited to representing surface detail rather than structural depth. Wherever possible baking normal maps from high-resolution meshes provides better representative solutions.

Design note: for more on making normal maps from images see "how NOT to make normal maps from images", "how to make normal maps from images" and "how to make normal maps from photographs".

Rock face with NO normal map

A 'cave' Scene in Blenders GLSL mode (so Materials with normal maps can be previewed live in the 3D View) - the rock surface is shown above without normal map (checkbox disabled) so depth is purely visual based on what's defined by the image itself...

Rock face with a converted image normal map

... but when a normal map produced from converting a grey-scale image is applied some depth and surface detailing starts to be seen...

Rock face that includes mesh baked normal map

... if the converted greyscale image is then combined with the 'gross' details provided by the normal map baked from the high resolution mesh, much better depth representation and detailing is visible (although not used here this effect can be further augmented using a 'displacement' or 'parallax' map)

Video clip showing the difference using mesh based normal maps make to in-game assets, in this instance an organic rocky cave structure (shown rendered in Blender under GLSL conditions)

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