I’m working on a script that, when all is said and done, will bake several textures and save them out as .tgas.
I’ve figured pretty much everything out except one thing – I cannot bake the material texture without having shadows. The ctrl+alt+b > Textures function does exactly what I want, but I would like to automate this particular step.
My script will bake a rendered version of the texture including shadows using the .bake() function. How do you get a non-shadowed, full-intensity texture bake?
What I like to do is go to the bake panel and hit the ‘texture’ button
Is there a way to see the internal python commands when you use the regular ‘texture only’ bake button?
I’m thinking in the command prompt, but better…There’s got to be a way to see that eh?
Is there a way to see the internal python commands when you use the regular ‘texture only’ bake button?
I’m thinking in the command prompt, but better…There’s got to be a way to see that eh?
I would rather know that, than simply the answer to my original question
I do a lot of VBA at work, and the record function helps tremendously. If only Blender had such a thing, eh?
That’s what I’ve been looking at, Sanne. Unfortunately, the API docs didn’t mention that the bake modes were integers. (bakeMode = 1) I also discovered that half of the items in the API were actually links (don’t know how I missed that, either), so I was able to drill down and find everything I needed.
Of course, I don’t have the script in front of me, but I’ll paste the snippet that answered my question here when I get back to my Blender computer.
Ah. That makes sense. I was just doing bakeMode = ‘TEXTURE’, not the full Blender.Scene… part.
Though, now I’m stuck with one issue – how do you create a new, blank (all black) UV image and assign it to all selected objects?
Image.New('imagename', 2048, 2048, 24)
makes my image for me, and then
image = Image.Get('imagename')
image.useCurrent()
sets the UV layer, but I don’t see the actual blank image there.
When I then run my bake, I get the “no images” error. That implies that the image isn’t actually active on the various objects. How can I set a particular image as the active UV layer for all selected objects?
For assigning this image as texture to all faces of the object, I believe (I hope it’s the correct way) you need to go via the Mesh module. Get the mesh data from your object, then get the faces for this mesh, loop through them and set the image as texture to each face. Look here for the image attribute of Blender.Mesh.MFace.
Here’s an example that loops through all selected mesh objects in a scene, adds a new uv layer to those objects and sets the last added uv layer to the active layer for each mesh. After looping, the button windows are redrawn to update the uv layer list (in case it is open).
I hope this helps you with your script.
import Blender
scn = Blender.Scene.GetCurrent()
selobs = [ob for ob in scn.objects.selected if ob.type == "Mesh"]
for ob in selobs:
me = ob.getData(mesh=True)
me.addUVLayer("myuv")
me.activeUVLayer = me.getUVLayerNames()[-1]
me.update()
Blender.Window.Redraw(Blender.Window.Types.BUTS)