Python script pb from CUDA to OPENCL

I have got a problem with the below script.
I works fine in CUDA bot not in OPENCL.
In fact everyting seems fine up to the texture creation. It looks OK with CUDA but is black with OPENCL (seems not to be created).
An expert help is welcome.

Here is the script:

import bpy
import math

scene = bpy.context.scene
bpy.ops.object.select_all(action=‘SELECT’)
bpy.ops.object.delete()

bpy.ops.object.text_add(location = (0, 0, 0.0015), rotation = (1.5708, 0, -1.5708))
text = bpy.data.objects[‘Text’]
text.scale = (0.01, 0.01, 0.007)
text.data.body = ‘TEST’
font = bpy.data.fonts.load(‘arial-black.ttf’)
text.data.font = font
bpy.context.object.data.align = ‘CENTER’
bpy.context.object.data.extrude = 0.1
bpy.context.object.data.bevel_depth = 0.02
bpy.context.object.data.space_character = 1.5

bpy.ops.curve.primitive_bezier_circle_add(location = (0,0,0), rotation=(0,0,1.5708))
bezier = bpy.data.objects[‘BezierCircle’]
bezier.scale = (0.041, 0.0237, 1)

text.modifiers.new(“Curve”, type=‘CURVE’)
text.modifiers[‘Curve’].object = bezier

#gradient colors : 6e1f6d - d3b9d2

delete all materials

for material in bpy.data.materials:
material.user_clear();
bpy.data.materials.remove(material);

create the emission material

mat = bpy.data.materials.new(name=“gradient”)
mat.use_nodes = True

get the nodes

nodes = mat.node_tree.nodes

clear all nodes to start clean

for node in nodes:
nodes.remove(node)

create output node

node_output = nodes.new(type=‘ShaderNodeOutputMaterial’)
node_output.location = (1300,0)

create diffuse node

node_diffuse = nodes.new(type=‘ShaderNodeBsdfDiffuse’)
node_diffuse.location = (1100,0)

create colorRamp node

node_colorRamp = nodes.new(type=‘ShaderNodeValToRGB’)
node_colorRamp.location = (800,0)
node_colorRamp.color_ramp.elements[0].color = [0.156, 0.014, 0.153, 1]
node_colorRamp.color_ramp.elements[1].color = [0.651, 0.485, 0.644, 1]

create GradientTexture node

node_gradientTexture = nodes.new(type=‘ShaderNodeTexGradient’)
node_gradientTexture.location = (600,0)

create Mapping node

node_mapping = nodes.new(type=‘ShaderNodeMapping’)
node_mapping.location = (200,0)
node_mapping.rotation.x = math.pi/2
node_mapping.rotation.y = math.pi/2

create TextureCoordinate node

node_textureCoordinate = nodes.new(type=‘ShaderNodeTexCoord’)
node_textureCoordinate.location = (0,0)

link nodes

links = mat.node_tree.links
link = links.new(node_textureCoordinate.outputs[0], node_mapping.inputs[0])
link = links.new(node_mapping.outputs[0], node_gradientTexture.inputs[0])
link = links.new(node_gradientTexture.outputs[0], node_colorRamp.inputs[0])
link = links.new(node_colorRamp.outputs[0], node_diffuse.inputs[0])
link = links.new(node_diffuse.outputs[0], node_output.inputs[0])

text.data.materials.append(bpy.data.materials[‘gradient’])
bpy.data.curves[“Text”].space_character = 1.1

convert text to mesh

bpy.ops.object.select_all(action=‘DESELECT’)
text.select = True
scene.objects.active = text
bpy.ops.object.convert(target=‘MESH’)

create texture

bpy.ops.object.mode_set(mode=‘EDIT’)
bpy.ops.mesh.select_all(action=‘TOGGLE’)
bpy.ops.uv.smart_project()
bpy.ops.image.new(name=“baked”, width=256, height=256)
image = bpy.data.images[“baked”]

create ImageTexture

node_imageTexture = nodes.new(type=‘ShaderNodeTexImage’)
node_imageTexture.location = (1300, -200)
node_imageTexture.image = image
node_imageTexture.select = True
nodes.active = node_imageTexture

scene.cycles.device = ‘GPU’
scene.render.engine = ‘CYCLES’

bpy.ops.object.bake(type=‘DIFFUSE’, pass_filter={‘COLOR’})

bpy.ops.object.mode_set(mode=‘OBJECT’)

scene.render.engine = ‘BLENDER_RENDER’

bpy.ops.object.modifier_add(type=“MULTIRES”)
bpy.data.objects[‘Text’].modifiers[“Multires”].subdivision_type = “SIMPLE”
bpy.ops.object.multires_subdivide(modifier=“Multires”)
bpy.ops.object.modifier_apply(modifier=“Multires”)

bpy.ops.object.mode_set(mode=‘EDIT’)

image.filepath_raw = “Text.jpg”
image.file_format = ‘JPEG’
image.save()

bpy.data.screens[‘UV Editing’].areas[1].spaces[0].image = image

export_path = “Text.obj”
bpy.ops.export_scene.obj(filepath=export_path, check_existing = False, use_selection = True)

If i start Blender in OpenCL enabled mode and look what’s in Terminal i see:


Compiling sum_all_radiance OpenCL kernel ...
Build flags: -D__SPLIT_KERNEL__ -D__WORK_STEALING__ -D__NODES_MAX_GROUP__=3 -D__NODES_FEATURES__=7 -D__MAX_CLOSURE__=64 -D__NO_HAIR__ -D__NO_OBJECT_MOTION__ -D__NO_CAMERA_MOTION__ -D__NO_BAKING__ -D__NO_VOLUME__ -D__NO_SUBSURFACE__ -D__NO_BRANCHED_PATH__ -D__NO_PATCH_EVAL__ -D__COMPUTE_DEVICE_GPU__

I believe -D__NO_BAKING__ should ring a bell.

Edit: If Experimental Feature Set is on flag NO_BAKING is not present however bake still results into a black image. Blender 2.78RC, 95cb714, GTX750