I want to make a script that bake a curvature texture at the resolution set automatically (i am creating a script that bakes every maps at once).
The script needs to create a textures, use the resolution entered, create a material with an emit shader and for the input a Geometry > Pointiness then a Color Ramp at 0.4 then 0.6.
It needs also to check is there is an existing node and texture with the same name already, if yes it should remove it. Then the script save the texture.
I have started the beginning of the script, the material part is missing:
import bpy
size = 2048, 2048
# create the texture, delete the old texture
image = bpy.data.images.new("curvature", width=size[0], height=size[1])
# create the material nodes, delete the old texture
bpy.data.materials.new("CURVATURE")
# to use once the material is created correctly
#bpy.data.objects['HP'].active_material = bpy.data.materials['CURVATURE']
#bpy.data.objects['LP'].active_material = bpy.data.materials['CURVATURE']
#bpy.ops.object.bake(type="EMIT", use_selected_to_active = True, use_cage = True, cage_extrusion = cage_size, margin = edge_padding, use_clear = True)
#need to get the name of the image on the variable image
image.filepath_raw = "//curvature.png"
image.file_format = 'PNG'
image.save()