Cycles baking artifacts
Closed, ResolvedPublic


System Information
Windows 10 16GB, GTX 965 2GB

Blender Version
Broken: 2.78.5(2acd05b) is broken along with every newer version that I tested.
Worked: 2.78.4(67bef6b) works as expected

Short description of error

There are strange dark artifacts showing up for simple blocks that are placed near one another. The artifacts that show up look like they are being baked in from some hidden object but there are no other objects hidden in the scene nor are there objects on any other layer.

The error happens for both CPU and GPU and also for 'Combined' and 'Ambient Occlusion' bakes.

Exact steps for others to reproduce the error
Open the included blend file and press bake.

Dalai Felinto (dfelinto) triaged this task as "Confirmed" priority.Tue, Aug 29, 12:35 PM

This was introduced in rBae1c1cd8c0da.
(and @marc dion (marcclintdion) thanks for nailing down the bad/good range, it sped up the git bisecting here)

@Dalai Felinto (dfelinto) It looks like I can get away with saying "you're welcome" since no one else is subscribed yet(no one around to annoy with undue email notifications ;). I just wish I had noticed it earlier, I've been too busy to use Blender much since last winter, I just wanted to test the bevel node.

Face splitting code is not the issue here. Took me some time to dig the culprit out of the shadows: our (old) quad rule stating that 'forth vertex of quad cannot be first one in mesh array (i.e. one with index 0), because we use zero forth vert index in our old (now only used for tessellation) Face data to mark it as a triangle. So... funny tessellation code has to rotate quad faces which happen to end on zeroth vertex.

Fun fact is, after faces have been split, two of the three that were using zeroth vert are now using newly generated ones, with higher indices, which mean tessellation will not rotate them anymore.

So, the issue here is the mismatch between Cycles code (object_to_mesh() in blender_utils.h) and baking code (bake_mesh_new_from_object() in object_bake_api.c), the later always splitting faces, while the former only does in in some specific cases. This leads to mismatches between generated meshes, in some unfortunate cases, a few faces will be rotated.

Am not sure how to solve this right (first and simplest idea would be to bring face splitting or not in baking code to match the one in Cycles - but we do not have access to Cycles subsurf stuff here afaik). But this is not my area of code really, should be handled by someone understanding baking/Cycles code better.

And this is not actually a regression, at least not from rBae1c1cd8c0da. The issue potentially exists since we use BMesh and polygons, it just did not triggered for some reason in this example with previous (rather broken) splitting code, but pretty sure one could forge faulty cases with previous code as well. It's mostly a matter of specific unfortunate corner case here.

This comment was removed by marc dion (marcclintdion).
This comment was removed by marc dion (marcclintdion).