In this script I use the addon blender for to make a terrain model with dem images.
The images dem are georeferenced.
The script imports dem images and makes the point cloud for every two meters, applies the delauny modifier.
And makes a simple plane for bake the normal map.
Select the simple plane and select the high mesh.
How can I apply the bake in this code?
Whith the options …Bake Mode = Normals
Selected to Active
And save the normalMap texture in the same folder of the original dem images, with 100 of quality.
Thanks for your help Secrop but my knowledge about programming is very few.
I try to use your code but it isn’t work.
Do I have to fill all options?
I try whith this code but it isn’t work:
Theoretically, when a function call has parameters with a default (like 'type = ‘NORMAL’), you don’t need to add the parameter to the call (unless you want to use some other parameter value instead of the default one).
So ‘bpy.ops.object.bake(type=‘NORMAL’, use_selected_to_active=True)’ should be enough. In my custom blender, this however does not work correctly… it bakes something, but not any normal map I can use (can’t say it’s a blender problem or some thing I messed up in my source).
Confess that I don’t really know much about baking normals… I mean, I do bake normals all the time, but I don’t use Blender’s native ‘bake normals’, as I never got any good normal map from it.
In this scene I have eigth meshes, four meshes low Poly and four high Poly.
With this script I make a diccionari and select the elements first mesh high poly and then mesh low poly and bake de texture.
But the script don’t bake the texture.
code:
import bpy, os
bpy.context.scene.render.bake_type = ‘NORMALS’
bpy.context.scene.render.use_bake_selected_to_active = True
objetos_escena = bpy.data.objects
bpy.ops.object.select_all(False)
objetos_dict = {}
for objeto in objetos_escena:
if objeto.type ==“MESH”:
objeto.select = False
nombre = objeto.name
values = nombre.split(’_’)
if values[0] in objetos_dict.keys():
objetos_dict[values[0]].append(objeto)
else:
objetos_dict[values[0]] = [objeto]
for key in objetos_dict.keys():
bpy.ops.object.select_all(False)
list = objetos_dict[key]
list[0].select = True
list[1].select = True
bpy.ops.object.bake_image()
bpy.ops.object.select_all(False)
If I select manually the mesh hig poly and low poly and execute only this lines:
import bpy, os
bpy.context.scene.render.bake_type = ‘NORMALS’
bpy.context.scene.render.use_bake_selected_to_active = True
bpy.ops.object.bake_image()
The texture is bake.
why razon when I select whit script and apply bpy.ops.object.bake_image() in this code… don’t work the bake?