Page MenuHome

Selected to Active Cycles Baking no longer working
Closed, ResolvedPublic


System Information
OSX 10.9.5

Blender Version
Broken: master (d39e188)
Worked: 2.75a

Short description of error
Baking returns a black image when using "Selected to Active" (it works fine otherwise).

Exact steps for others to reproduce the error
Compare either file below between master and 2.75a. They all bake the diffuse color for simplicity sake.

Selected to Active (not working):

  • Color:
  • Texture:

Single object (working):

Event Timeline

Dalai Felinto (dfelinto) set Type to Bug.
Dalai Felinto (dfelinto) created this task.
Dalai Felinto (dfelinto) raised the priority of this task from to Needs Triage by Developer.

I will try to git bisect this later, but I think it's related to the mesh changes Blender is going through. So maybe @Antony Riakiotakis (psy-fi) or @Campbell Barton (campbellbarton) would know better where to look at.

I think it's safe to assume that the conversion to looptri commit broke this.

Found it c61e4f2683c0d7207948c06d028adfe67c67270c

Asan report:

==11340== ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fec523909d0 sp 0x7fec11731638 bp 0x7fec11731e80 T31)
AddressSanitizer can not provide additional info.
    #0 0x7fec523909cf in __sanitizer_report_error_summary ??:?
    #1 0x7fec523853a2 in ctime_r ??:?
    #2 0x3437f74 in cdDM_copyTessFaceArray /home/dfelinto/blender/git/blender/source/blender/blenkernel/intern/cdderivedmesh.c:157
    #3 0x33b1276 in dm_getTessFaceArray /home/dfelinto/blender/git/blender/source/blender/blenkernel/intern/DerivedMesh.c:139
    #4 0x33c3826 in DM_add_tangent_layer /home/dfelinto/blender/git/blender/source/blender/blenkernel/intern/DerivedMesh.c:3016
    #5 0x2781be4 in mesh_calc_tri_tessface /home/dfelinto/blender/git/blender/source/blender/render/intern/source/bake_api.c:372
    #6 0x278289d in RE_bake_pixels_populate_from_objects /home/dfelinto/blender/git/blender/source/blender/render/intern/source/bake_api.c:475
    #7 0x2469f08 in bake /home/dfelinto/blender/git/blender/source/blender/editors/object/object_bake_api.c:788 (discriminator 3)
    #8 0x246d87c in bake_startjob /home/dfelinto/blender/git/blender/source/blender/editors/object/object_bake_api.c:1157
    #9 0x1982920 in do_job_thread /home/dfelinto/blender/git/blender/source/blender/windowmanager/intern/wm_jobs.c:331
    #10 0x4109068 in tslot_thread_start /home/dfelinto/blender/git/blender/source/blender/blenlib/intern/threads.c:254
    #11 0x7fec5238fb97 in __asan_describe_address ??:?
    #12 0x7fec4fbb2181 in start_thread /build/buildd/eglibc-2.19/nptl/pthread_create.c:312 (discriminator 2)
    #13 0x7fec4cfb547c in clone /build/buildd/eglibc-2.19/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:111

in multiresbake_create_loresdm,
after calling CDDM_from_mesh, DM_ensure_tessface(cddm); should create the data thats needed.

@Campbell Barton (campbellbarton) I tried with your patch but I still get a crash:

==26075== ERROR: AddressSanitizer: heap-buffer-overflow on address 0x601e0003bff8 at pc 0x4063638 bp 0x7f034c2dbf80 sp 0x7f034c2dbf78
READ of size 4 at 0x601e0003bff8 thread T35
    #0 0x4063637 in normal_tri_v3 /home/dfelinto/blender/git/blender/source/blender/blenlib/intern/math_geom.c:72
    #1 0x27870e8 in mesh_calc_tri_tessface /home/dfelinto/blender/git/blender/source/blender/render/intern/source/bake_api.c:403
    #2 0x2787399 in RE_bake_pixels_populate_from_objects /home/dfelinto/blender/git/blender/source/blender/render/intern/source/bake_api.c:448
    #3 0x246dbe9 in bake /home/dfelinto/blender/git/blender/source/blender/editors/object/object_bake_api.c:788 (discriminator 3)
    #4 0x247155d in bake_startjob /home/dfelinto/blender/git/blender/source/blender/editors/object/object_bake_api.c:1157
    #5 0x19836d3 in do_job_thread /home/dfelinto/blender/git/blender/source/blender/windowmanager/intern/wm_jobs.c:331
    #6 0x4114aae in tslot_thread_start /home/dfelinto/blender/git/blender/source/blender/blenlib/intern/threads.c:254
    #7 0x7f0392386b97 in __asan_describe_address ??:?
    #8 0x7f038fba9181 in start_thread /build/buildd/eglibc-2.19/nptl/pthread_create.c:312 (discriminator 2)
    #9 0x7f038cfac47c in clone /build/buildd/eglibc-2.19/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:111
0x601e0003bff8 is located 0 bytes to the right of 168-byte region [0x601e0003bf50,0x601e0003bff8)
allocated by thread T35 here:

Patch used:

diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index bd847fc..3bce90d 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -215,6 +215,7 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l
                tmp_mmd.simple = true;
+       DM_ensure_tessface(cddm);
        DM_set_only_copy(cddm, CD_MASK_BAREMESH | CD_MASK_MFACE | CD_MASK_MTFACE);
        tmp_mmd.lvl = *lvl;
Aaron Carlisle (Blendify) triaged this task as Confirmed, Medium priority.

Just a heads up because it might be related, baking seems to be checking for gpu even when it's not the chosen render device. Not usually an issue, but if your build doesn't support your gpu shader model this crashes Blender even with CPU selected.

The crash is gone (after rBe229d66 thanks @Campbell Barton (campbellbarton)) but the baking is still black.

New sample file:

Run it with ./blender -y -b cycles_bake_red_pixel.blend It prints RED when it works, and BLACK when it fails.

It's a 1 pixel sample file.