diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-04-22 21:44:49 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-04-23 00:15:45 +0300 |
commit | 6787cc13d4efef19eb708e1912356f8c1d4d2e01 (patch) | |
tree | 7281d706ec6aad566306d12632cd6d7d6f8f462a /source/blender/editors/object/object_bake.c | |
parent | bdc537e0a7b4b62af049dd4d508d5b08a4fa8b3b (diff) |
Bake: add UDIM tile baking support
Works for both Cycles and multires bake. Triangles are baked to multiple
UDIM images if they span across them, though such UV layouts are generally
discouraged as there is no filtering across UDIM tiles.
The bake margin currently only works within UDIM tiles. For the extend method
this is logical, for the adjacent faces method it may be useful to support
copying pixels from other UDIM tiles, though this seems somewhat complicated.
Fixes T95190
Ref T72390
Diffstat (limited to 'source/blender/editors/object/object_bake.c')
-rw-r--r-- | source/blender/editors/object/object_bake.c | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index d469efbd0a1..1483c24ac70 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -172,28 +172,35 @@ static bool multiresbake_check(bContext *C, wmOperator *op) ok = false; } else { - ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); + LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) { + ImageUser iuser; + BKE_imageuser_default(&iuser); + iuser.tile = tile->tile_number; - if (!ibuf) { - BKE_report(op->reports, RPT_ERROR, "Baking should happen to image with image buffer"); + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL); - ok = false; - } - else { - if (ibuf->rect == NULL && ibuf->rect_float == NULL) { - ok = false; - } + if (!ibuf) { + BKE_report( + op->reports, RPT_ERROR, "Baking should happen to image with image buffer"); - if (ibuf->rect_float && !(ELEM(ibuf->channels, 0, 4))) { ok = false; } - - if (!ok) { - BKE_report(op->reports, RPT_ERROR, "Baking to unsupported image type"); + else { + if (ibuf->rect == NULL && ibuf->rect_float == NULL) { + ok = false; + } + + if (ibuf->rect_float && !(ELEM(ibuf->channels, 0, 4))) { + ok = false; + } + + if (!ok) { + BKE_report(op->reports, RPT_ERROR, "Baking to unsupported image type"); + } } - } - BKE_image_release_ibuf(ima, ibuf, NULL); + BKE_image_release_ibuf(ima, ibuf, NULL); + } } } } @@ -274,21 +281,27 @@ static void clear_single_image(Image *image, ClearFlag flag) const float disp_solid[4] = {0.5f, 0.5f, 0.5f, 1.0f}; if ((image->id.tag & LIB_TAG_DOIT) == 0) { - ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL); + LISTBASE_FOREACH (ImageTile *, tile, &image->tiles) { + ImageUser iuser; + BKE_imageuser_default(&iuser); + iuser.tile = tile->tile_number; - if (flag == CLEAR_TANGENT_NORMAL) { - IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? nor_alpha : nor_solid); - } - else if (flag == CLEAR_DISPLACEMENT) { - IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? disp_alpha : disp_solid); - } - else { - IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid); - } + ImBuf *ibuf = BKE_image_acquire_ibuf(image, &iuser, NULL); - image->id.tag |= LIB_TAG_DOIT; + if (flag == CLEAR_TANGENT_NORMAL) { + IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? nor_alpha : nor_solid); + } + else if (flag == CLEAR_DISPLACEMENT) { + IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? disp_alpha : disp_solid); + } + else { + IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid); + } + + image->id.tag |= LIB_TAG_DOIT; - BKE_image_release_ibuf(image, ibuf, NULL); + BKE_image_release_ibuf(image, ibuf, NULL); + } } } |