Cycles versus Blender Internal
As we have seen previously, texture baking in Blender Internal can be very efficient to produce normal maps, ambient occlusion, color textures, and many other kinds of maps that we won't cover here. All of this in a very short time. So you might wonder why it is interesting to bake in Cycles.
Cycles is a ray tracer render engine based on physical parameters with global illumination. It is then possible to get some very realistic renders in a much more efficient manner. Baking in Cycles allows us, for example, to calculate a few heavy special effects only once, such as caustics. When a render is baked on a texture, you can visualize the effect in real time. This can be very useful if you want to change the frame and make several renders. In this way, it is possible to create a realistic environment in real time.
However, in the context of a video game, if you have many dynamic assets you must pay attention. You could be limited by fixed lighting. Even though baking in Cycles can be very interesting, it has some faults. Doing a good baking without noise requires the same settings as a normal render, so you do need a high sampling value, which greatly increases rendering time compared to Blender Internal.
We won't bake the maps of every objects in our scene with Cycles; however, we will see how to proceed with the 3D mesh of the tree as an example.
In order to optimize the render time, we will import our 3D mesh to another Blender window:
- We will launch Blender a second time.
- We will select the tree in the scene of the haunted house, and we will press Ctrl + C to copy it. You will see the Copied selected object to buffer message in the header of the work space.
- In the other Blender window, we will press Ctrl +V to paste the tree. We will see the Objects pasted from buffer message.
- In the same way, we will also import all the lights, and we must recreate the shader of the Image Base Lighting (we can append it from the main file). We don't modify the location of the tree and the lights in order to keep the same light configuration. But this wont be exactly the same lighting effect as we don't have the house here.
- We will need a second UVs layer with UVs that are restrained in the UV square this time. We will use the Ctrl + P shortcut to automatically replace the UVs. Then we will adjust the margin in the options of the left panel of the 3D viewport.
- We will start with color baking using the new UVs. For this, we will add an Image Texture node (Shift + A and select Texture | Image Texture) to the shader of the tree.
- We will select all the polygons of the tree in the Edit Mode (Tab and A), and then we will create a new image named Tree_Color. A size of 2048 x 2048 is enough.
- In the Image texture node that we have just created, we will select the Tree_Color texture. This node must stay u.nconnected.
- Now we will need to go into the Bake tab in the Render options. Here, we will change the type to Diffuse Color. We will set the Margin value to 5, and then we will press Bake.
- When we have our color map, we must adjust the seams with Texture Paint. We will use the Soften Brush in order to blur the problems of the too visible seams.
- When the color texture is fine, we will again select the polygons of the tree in the Edit Mode, and we will create a new image (the same size) and rename it as Tree_Combined.
- Now we can make another combined baking following the same process, which this time allows us to get all the lighting information on the texture. Make sure you open the good image in the Image Texture node with a high enough sample value. In our case, we have 500 samples to obviate the noise.
- We can now go back to our haunted house scene and replace the tree with the one with new UVs (Ctrl + C and Ctrl + V); then we can replace the old texture with the Tree Combined texture in our shader.