Cycles bake (bpy.ops.object.bake) unstable when using uv_layer parameter #60093

Closed
opened 2019-01-02 23:44:12 +01:00 by Adam Dominec · 6 comments
Member

Operating system: Ubuntu Linux 4.13.0-25-generic
Graphics card: none (Mesa using integrated i3-6100U)

Broken: 2.80, blender/blender@df3e7d0361 2018-12-27 from [[ https://launchpad.net/~thomas-schiex/+archive/ubuntu/blender/+packages?field.name_filter=blender-next&field.status_filter=published&field.series_filter=cosmic | thomas-schiexs PPA ]] Calling bpy.ops.object.bake(uv_layer="UVMap")` has unpredictable results and often crashes Blender. I discovered three issues, probably related:

  • Start from the default file and just add an Image Texture to the default cube so that there is a Bake target.
  • Execute bpy.ops.object.bake(uv_layer="UVMap") from the Python Console. The result is wrong.

OR

  1. Start from the default file and run this script from the Text editor:
import bpy
C = bpy.context
me = C.object.data
C.scene.render.engine = 'CYCLES'
image = bpy.data.images.new("Image", 100, 100, alpha=True)
for mat in me.materials:
    img = mat.node_tree.nodes.new('ShaderNodeTexImage')
    img.image = image
    mat.node_tree.nodes.active = img
tex = me.uv_layers.new(name="Tex 1")
C.object.update_from_editmode()
bpy.ops.object.bake(uv_layer=tex.name)
  1. Blender crashes. Backtrace usually shows Cycles ccl::triangle_point_normal, sometimes ccl::shader_setup_from_sample.

OR

Start from the default file and run this code in the Text editor:

import bpy
C = bpy.context
sce = C.scene
me = C.object.data
sce.render.engine = 'CYCLES'
image = bpy.data.images.new("Image", 100, 100, alpha=True)
for mat in me.materials:
    img = mat.node_tree.nodes.new('ShaderNodeTexImage')
    img.image = image
    mat.node_tree.nodes.active = img
tex1 = me.uv_layers.new(name="Tex 1")
tex2 = me.uv_layers.new(name="Tex 2")

square = ((0, 0), (1, 0), (1, 1), (0, 1))
for face in me.polygons:
    for l, (x, y) in zip(face.loop_indices, square):
        tex1.data[l].uv = x * 0.5, y
        tex2.data[l].uv = x, y * 0.5
me.uv_layers.active = me.uv_layers[tex1.name]
C.object.update_from_editmode()
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.object.mode_set(mode='OBJECT')
  1. Run this command in Python Console:
bpy.ops.object.bake(uv_layer="Tex 2")
  1. Blender crashes, same as above.
Operating system: Ubuntu Linux 4.13.0-25-generic Graphics card: none (Mesa using integrated i3-6100U) Broken: 2.80, blender/blender@df3e7d0361 2018-12-27 from [[ https://launchpad.net/~thomas-schiex/+archive/ubuntu/blender/+packages?field.name_filter=blender-next&field.status_filter=published&field.series_filter=cosmic | thomas-schiex`s PPA ]] Calling `bpy.ops.object.bake(uv_layer="UVMap")` has unpredictable results and often crashes Blender. I discovered three issues, probably related: - Start from the default file and just add an Image Texture to the default cube so that there is a Bake target. - Execute `bpy.ops.object.bake(uv_layer="UVMap")` from the Python Console. The result is wrong. OR 1. Start from the default file and run this script from the Text editor: ``` import bpy C = bpy.context me = C.object.data C.scene.render.engine = 'CYCLES' image = bpy.data.images.new("Image", 100, 100, alpha=True) for mat in me.materials: img = mat.node_tree.nodes.new('ShaderNodeTexImage') img.image = image mat.node_tree.nodes.active = img tex = me.uv_layers.new(name="Tex 1") C.object.update_from_editmode() bpy.ops.object.bake(uv_layer=tex.name) ``` 2. Blender crashes. Backtrace usually shows Cycles `ccl::triangle_point_normal`, sometimes `ccl::shader_setup_from_sample`. OR # Start from the default file and run this code in the Text editor: ``` import bpy C = bpy.context sce = C.scene me = C.object.data sce.render.engine = 'CYCLES' image = bpy.data.images.new("Image", 100, 100, alpha=True) for mat in me.materials: img = mat.node_tree.nodes.new('ShaderNodeTexImage') img.image = image mat.node_tree.nodes.active = img tex1 = me.uv_layers.new(name="Tex 1") tex2 = me.uv_layers.new(name="Tex 2") square = ((0, 0), (1, 0), (1, 1), (0, 1)) for face in me.polygons: for l, (x, y) in zip(face.loop_indices, square): tex1.data[l].uv = x * 0.5, y tex2.data[l].uv = x, y * 0.5 me.uv_layers.active = me.uv_layers[tex1.name] C.object.update_from_editmode() bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.mode_set(mode='OBJECT') ``` 2. Run this command in Python Console: ``` bpy.ops.object.bake(uv_layer="Tex 2") ``` 3. Blender crashes, same as above.
Author
Member

Added subscriber: @emu-3

Added subscriber: @emu-3

Added subscriber: @ZedDB

Added subscriber: @ZedDB

I can't seem to reproduce this issue. Could you see if you still get this with the latest blender beta?
IIRC there has been some fixes to cycles baking.

I can't seem to reproduce this issue. Could you see if you still get this with the latest blender beta? IIRC there has been some fixes to cycles baking.
Author
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Adam Dominec self-assigned this 2019-02-08 14:41:28 +01:00
Author
Member

Cool, it seems to be fixed in current daily builds. I close my bug report as resolved.

Cool, it seems to be fixed in current daily builds. I close my bug report as resolved.
Author
Member

I couldn't check that the bake result is correct. Yesterday's daily build crashes upon clicking the image dropdown menu in Image editor or UV editor. That's an unrelated issue, and I'll wait a day or two before reporting it.

I couldn't check that the bake result is correct. Yesterday's daily build crashes upon clicking the image dropdown menu in Image editor or UV editor. That's an unrelated issue, and I'll wait a day or two before reporting it.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#60093
No description provided.