Fix T77298: Can't bake texture with multiple objects
The problem here is that the baking code uses tiles to exchange pixel data with the renderer since a recent-ish refactor, but the code that sent data to the renderer did not initialize the bake result pixels. Therefore, when the baking process for the second object started, Cycles received empty tiles and sent them back as-is if the second object did not cover them. By initializing the tiles with the result of the previous bakes, we avoid this problem.
This commit is contained in:
parent
8ef05d3180
commit
bc5d144855
Notes:
blender-bot
2023-02-14 01:35:49 +01:00
Referenced by issue #77298, Can't bake texture with multiple objects.
|
@ -174,7 +174,8 @@ static RenderResult *render_result_from_bake(RenderEngine *engine, int x, int y,
|
|||
BLI_addtail(&rr->layers, rl);
|
||||
|
||||
/* Add render passes. */
|
||||
render_layer_add_pass(rr, rl, engine->bake.depth, RE_PASSNAME_COMBINED, "", "RGBA");
|
||||
RenderPass *result_pass = render_layer_add_pass(
|
||||
rr, rl, engine->bake.depth, RE_PASSNAME_COMBINED, "", "RGBA");
|
||||
RenderPass *primitive_pass = render_layer_add_pass(rr, rl, 4, "BakePrimitive", "", "RGBA");
|
||||
RenderPass *differential_pass = render_layer_add_pass(rr, rl, 4, "BakeDifferential", "", "RGBA");
|
||||
|
||||
|
@ -210,6 +211,15 @@ static RenderResult *render_result_from_bake(RenderEngine *engine, int x, int y,
|
|||
}
|
||||
}
|
||||
|
||||
/* Initialize tile render result from full image bake result. */
|
||||
for (int ty = 0; ty < h; ty++) {
|
||||
size_t offset = ty * w * engine->bake.depth;
|
||||
size_t bake_offset = ((y + ty) * engine->bake.width + x) * engine->bake.depth;
|
||||
size_t size = w * engine->bake.depth * sizeof(float);
|
||||
|
||||
memcpy(result_pass->rect + offset, engine->bake.result + bake_offset, size);
|
||||
}
|
||||
|
||||
return rr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue