Help wth Baking all objects at once.

The problem I’m running into- In a scene with lots of object you want to bake you spend a lot of time setting up materials with 2 texture slots. One for the diffuse texture and the second for the full bake texture. The second texture slot has to be unchecked when you bake the full texture, then rechecked and the material set to shadeless to see the baked texture. This is massivly time consuming if you move the lights and want to reBake the entire scene.
I found an add-on that can set all selected objs to shaded or shadeless at once. There is also some simple code to do it. But what I’m hoping someone will help me out with is some simple code that can check or uncheck the texture slot of my choise on all selected objects.
Then the work flow for baking all selected objects in a scene would be:

  • one click to set objs to shaded
    -one click to set texture slot #2 to unchecked
    -one click on Bake full render-
    -click again to enable check on texture slot 2
    -click to set to unshaded.
    Can anybody help with this little script? Could be a huge time saver when baking lots of objects for a game. Thanks

Texture atlas seems to bake a light map to the second texture slot. Which is cool but it never seems to look as good as if I do a full render with lights and textures. That seems to capture suttle color shading in the diffuse map that looks better. So I was trying to figure out how to make it easy to do lots of objs with full render. Thanks for your feed back.

It is assumed that you will have a texture setup that mix the baked images with the original textures so they will be layered and display both.

TextureAtlas is used to set up the textures for baking, the method of baking (Full Render or other) is up to you.

So I think it is exactly what you are looking for, take a look at it again.

Hey thanks for all the help everybody, maybe I don’t understand TextureAtlas well enough. And thanks for the script Ucupumar. I look forward to trying it. By the way the addon “Display tools” (space_view3d_displaytool.py) is the one that has tabs for enabling or disabling all selected objs for shaded. Its available in the scripts repository.
I was trying out UDK a while back and the one thing that spoiled me was it had a one button calculate/ build/bake all static lights function. And I was just trying to implement something like that for Blender. Cause I’m never giving up on Blender.

Hey thanks for all the help everybody, maybe I don’t understand TextureAtlas well enough. And thanks for the script Ucupumar. I look forward to trying it. By the way the addon “Display tools” (space_view3d_displaytool.py) is the one that has tabs for enabling or disabling all selected objs for shaded. Its available in the scripts repository.
I was trying out UDK a while back and the one thing that spoiled me was it had a one button calculate/ build/bake all static lights function. And I was just trying to implement something like that for Blender. Cause I’m never giving up on Blender.

I also found this little script that enable shadeless.

import the Blender module

import bpy

#Iterate over all members of the material struct
for item in bpy.data.materials:
#Enable “use_shadeless”
item.use_shadeless = True

Obviously if you set it to false it disables shadeless

Finally got around to trying Ucupumar’ script and it works great. One click causes the texslot to set to untrue, then bakes, then sets it back to true. I’m going to try to add in the little script above to also set it to shaded, then do the bake and set it back to shadeless. I not a programmer but i’ll trial and error it for a while. If you can do all these tedious bake steps with one click it should be made into a button that resides in the Bake panel as an extra option. Blender needs lots of simplifed buttons like that to make complex operations simpler and faster and more obvious to the user. Thanks again for the script