Blender Techniques (for game developers)
This page covers multiple useful Blender techniques that are especially useful for game developers. Some basic knowledge about Blender may be required.
Creating Materials, Texture Baking & UV Mapping
So we made a "low-poly" model with a material in Blender:
Left: Scene overview. Right: With the normal Blender-Render rendered result.
The material has one diffuse texture and one texture for both normal and specular mapping:
You could also use more textures and/or the node editor to create a diffuse, normal or specular map. You can determine what kind of map they are by using the settings in the "Influence" area.
Before unwrapping: create a texture (I used 2048pxx2048px for each one. That was a bit low for the normal map, but may be enough depending on use case and limits).
The unwrap menu can be accessed by pressing U while in edit mode:
The most useful options are:
Smart UV Project: This mode uses connected faces to build connected areas. Important for the later baking: set an "Island Margin". 0.03 (one click on the right arrow) is often enough. There should be a margin of several pixels between the connected areas.
Lightmap Pack: This mode ignores connected faces at all. It tries to fill the whole texture equally with every face, depending on their relative sizes (relative big face = big area, small face = small area). This mode may be the best when wanting to use the available texture pixels in the most efficient way, but makes it quite impossible to edit the texture via painting on it.
Cube / Cylinder / Sphere Projection: Good for cubes, cylinders and spheres. Terrible for everything else. Important: This mode is often using UV coordinates outside the normal texture area. This gives problems when baking (could work but Blender's baking ignores texture wrapping).
Stitching with seams: Best option for some complicated cases, or if you want to draw on the texture, may be the half-manual technique of marking edges via "mark seam" (Mesh->Edges->Mark Seam) an then using "Unwrap". The mesh is divided manually into several areas, the boundary of each area is the seam.
Baking the Textures
The "Bake" area is in the "Render"-Tab:
Urho3D has several material techniques for different cases, like diffuse map + normal map + specular map. Depending on your case you may need other ones (too) like Alpha, Shadow or Ambient Occlusion. In my experience choosing "Specular Colors" to create the specular map creates better results as "Specular Intensity".
Baking in "Texture" mode yielded this result:
This is the diffuse texture (this is a Blender screenshot, the UV lines are not on the texture. But you can also create an image with the UV-Map-Lines on it, which makes painting textures easier.). I used "Smart UV Project" to get a better screenshot for explanation. "Lightmap Pack" may have been better and would have been my choice for this case (both because of the better pixel usage).
Create all the textures you want and remember to save every one after generating it.
Loading the Textures
After generating every texture, you need to exchange all Blender generated textures with the just generated images:
All textures that are not the maps that you want to load into Urho3D should be disabled. Every map should be set to its desired purpose in the influence area: set the diffuse map to Color 1.0 (and nothing else), the normal map to Normal 1.0 (and nothing else, like in the screenshot), and other maps like specular as well. Important for normal map: in the "Image Sampling" area you need to enable "Normal Map" with "Tangent" (like in the screenshot), or Blender will display the normal map weirdly. When done everything correctly, you should be able to see your fully textured model in the Blender view when being in object mode and material view (like in the screenshot on the left side).
See Blender to Urho3D Guide for a tutorial on how to export to Urho3D.
The model in Urho3D:
Left: after first loading the well into Urho3D. Right: after adjusting parameters in the material file, repositioning and rescaling the model and rotating the sunlight.
Using a High-Res Model to Create Normal Maps or other Textures on a Low-Res Model
I'm using the Blender monkey model called Suzanne as an example:
The normal low-poly model without any (active) texture and 507 vertices.
I made a copy, applied a subdivision surface modifier (with three subdivisions) and drew some lines with the sculpt tool to create a high-poly model out of it (with 126,290 vertices):
The Blender bake area is capable of using one model to create textures for another model. It can be used to create a normal map out of a high-poly version for a low-poly version of the same model:
You need to select both models (use shift) so that the low-poly model is the active one. This is display by the white text in the outline window (top right in the screenshot above). The selection is displayed by the filled circle behind the type icon (that thing between the + and the model name). Before baking, you need to create an UV-Map (I used "Smart UV Project" here), a texture and the texture needs to be saved (and also loaded into Blender I think, I loaded it as a texture in the texture tab and it worked). The checkbox "Selected to Active" in the bake area needs to be also checked to activate the model to model mode. The baking should produce a normal like the one seen in the screenshot. The models should be at the same position.
After saving, reloading, applying and configuring the normal map, my low-poly monkey head looked like this:
Yes these are still just 507 vertices! This technique is often used to make a low-poly model look much more detailed.
This can also be used to create (seemless) textures by making a 3D-Model (like a brick wall) and baking it to a plane (texture in the sense of being more generic and not so bound to a specific model as the monkey above).
Found a video that shows this as well: https://www.youtube.com/watch?v=8aS1P_29abs
[Anyone having ideas for more useful techniques?]