Be aware that baking has been added to blender’s souce!
This basicly means that this script has become outdated.
Find the official information about it here.
I will keep this script online, but I won’t be updating it
Blender Raytrace Baker
Originally written by macouno 31-05-2005
(current release version 16-07-2006 for blender 2.42)
This page explains a bit about what this script does and how you can use it.
Version 3.4 is written for the blender 2.42 official release. You can still download version 3 for older blender versions (3.4 should be fine but just to be sure I left it on here) The scripts uses both the os and math modules, which means that you need a full python install.
Loading the script
If you don’t know how to use scripts read this page.
The use and functions of the script
At the top of the gui you can read what version you are currently using.
On the top line you can read how many mesh objects are available in the current scene. On the second line you can read what object you have selected now. On the third line you can read how many faces your current object has.
If you don’t get the above you’ll get a message saying: No object with faces selected! Select one and press reset! Which I suggest you do 😉
Here you can select what layers you want to be rendered. Thus you can for instance have an object selected on layer one that you want to create a new baked texture for. But you can have the script render a higher poly version of the object on another layer.
In these 3 number fields you can set your basic camera settings. For normal use I advise you to keep them as is.
Sets the clipstart of your camera in the same way the Clipsta setting in your blender settings does. If you set this too small or too close to the c-dist value you may get clipping of faces.
Sets the distance buffer from the closest vert to the camera. The script calculates the absolute minimal distance from the midpoint between the verts to the camera. This will put it right at the closest vert. But blender needs a slight buffer for it to register a face. Thus we set the camera a little bit further away. This value should be bigger than the c-start value and smaller than the c-end value.
This one’s simple… It sets the Clipend for your camera in the same way the ClipEnd can be set in your normal camera settings. The clipend must be big enough to not only reach the distance of the first vert but the furthest vert in the face… thus we like to keep it large. Set it lower for quicker renders but usually you can leave it as is.
In this number field you can set what frame you want to render. It’s really only helpfull in case you want to render a specific frame in an animated sequence.
Here’s one to think hard about. When there are no uv coords available you will see a message in place of this toggle. No uv coords set! In normal modes it means that texface (edit buttons) is not enabled for this mesh. And normally this means there is not yet a uv layout to render to. In “all mesh” mode it means that one or more of your meshes do not have an available uv layout. When not selected the script will create all new uv coordinates for your mesh. The texture will be rendered onto a grid of squares. When selected the script will attempt to render to your uv layout. Be aware that if you have overlapping uv’s you will get unsatisfactory results.
Here you have two options for resetting which are normally selected. R scn When selected the new scene that’s created for tile to image conversion is not removed. Thus if you are getting errors you can use this to see if anything went wrong there. It’s really mostly there for me to see what’s happened. When in “all mesh” mode the button will be hidden and you can see the following text. Resetting! This because your blend file would get far too messy if left on. X tiles When selected all the temporary tile images created by the script will be removed after the render is complete. For testing purposes it can be handy to see everything that got done. I can come up with other applications but as a standard leave it selected.
When this button is selected the script will estimate optimal tile/image sizes every time you change one of their values. When you are in “all mesh” mode the button will disappear and the following text will be visible. Estimation is on! This means that reset has been switched on. This because setting tile sizes for all meshes according to the one you have selected is not practical (more on this later) You can of course swith estimation on to see what values it gives you, then switch it off and set the image size values to whatever you like.
Tile size relativity
Here you have 3 options for how you want your tile size to be calculated when estimation is switched on.
The tile size will be calculated relative to the longest edge’s length of each face. Use this mode if you have a lot of ‘non square’ faces. Long and thin faces may not have a large area which would normally mean they get rendered quite small. In this mode that won’t be such an issue.
The tile size will be calculated relative to the face area of your mesh. If you render to an existing uv layout it calculates the maximum face area relative to the maximum uv area. Then it calculates the minimum face area relative to that. If you don’t render to an existing uv layout the maximum tile and minimum tile sizes will be calculated relative to the total area of your mesh.
The tile size will be calculated relative to the uv layout of your mesh. If you have no available uv layout it will result in the same as a Non relative render. This mode calculates the face’s uv areas relative to the total uv area that’s available, not the total uv area that’s used.
When tile size is non relative all your tile images are the same exact size. The difference between the total image and tile images is calculated using the total number of faces in your mesh. This is the optimal setting for rendering to a new uv grid.
Normal image sizes
Here you can set the size of your renders. There are 3 available sliders.
This slider is only available when your render to relative image sizes. It sets the absolute smallest tile that will be rendered.
In non relative render mode this slider sets the size of your tiles. In relative render mode it sets the absolute maximum size for your tiles.
This sets the size of the total compilation uv texture image that will be rendered.
All mesh image sizes
When you select “all mesh” mode the normal image size sliders are replaced by these 2 sliders. The size for each image will be calculated relative to the total face area of your mesh. You can still select what estimation mode you want to use. But for practical purposes we’ll let the script calculate all the tile sizes. To see what those tile sizes will be for an object leave “all mesh” mode and select that object, then press reset.
The minimum size for the final uv textures.
The maximum size for the final uv textures.
The render path
Here you set the path where you want the files to be saved. You need a total path and filename without extention. So you can set: c:myfoldermyfilename But not: c:myfoldermyfilename.png The extention and frame nr will be added to the filename. In “all mesh” mode the object name will be added as well. If you don’t change the frame your default final imagefile name format will look like: myfilename0001.png If you are in “all mesh” mode it will look something like: myfilenametheboject0001.png
This one should be easy. You can select three image types.
Do not use jpg if you want to render with an alpha channel. I advise you to use PNG since it’s lossless but not as huge as Targa.
There are three render modes available.
All faces of your current mesh will be rendered
Only the selected faces (in face mode) will be rendered. Be aware that when you render in this mode to an existing uv layout it will also create the copies of this face needed for seamlesnes. So your image may look strange but it will be correct.
All the mesh objects in this scene will be rendered. Reset of scene will be enabled. Estimation will be enabled. To uv layout rendering will only be possible if all your meshes have a uv layout assigned. The image sliders will be set to minimum and maximum total image.
Here you have 3 options:
Run the script
Will start the rendering of your tiles.
Will try to reaquire the mesh you have selected. Will recalculate relative rendersizes relative to the total image size.
Exits the script.
Do’s and dont’s
Pitfalls and things to do before using the script
There is a flaw in the windows dirname function when you haven’t saved your current file before. This only impacts the script if you set a relative render path. So if your renderpath was //render It may print out ./render To solve it… either just type in the full path or save your blend file (and reopen the script). The bug is solved now (so I’m told) so if you have something more current than 2.37 this should be fine. The script will get errors if you have loose verts floating around in your mesh. For finding these problems I wrote the Mesh Checker script. Also you may want to run the script on a copy of your object. This because in regular mode (not original uv) it changes all the object’s uv coordinates. I advise against using specularity! The camera angle is different for each face so it’ll never match!
Straight edges and long faces
In the example on the left you can see the model on the left and the created uv layout on the right. As you can see the blue face only uses a small portion of the square part of the uv layout it resides in. Thus as a rule of thumb… try to make your faces as square as possible. In the example on the right you can see a small white edge in the black circle. On the right you can see that that’s where the uv image borders on the white background. This is because we’re using a true ortho camera straight in front of the face. It’s not an error in the script. All I can do is advise you to use rounded or beveled objects as much as possible. Or try to set a background color that matches your object somewhat
See through faces
If after rendering when you enter textured view mode you see slightly transparent faces like above. This means some faces are set with an alpha drawmode. To fix it select them all in face select mode (f) and click on the copy drawmode button in your edit buttons (texture face tab).
A nice example
I rendered this texture in a half hour. The tiles are only between 20 x 20 and 40 x 40 in size and I let it render relative to face area. Rendering this model shadeless with a high osa only takes around 2 seconds now… that’s a lot quicker than the 5 minutes it would take to raytrace it every time.
That means that after baking I can render my model 150X faster!
This is a figure by Sketchy… also baked 😉 If anyone else has some nice examples that they want to show, please send them to me.