diff options
Diffstat (limited to 'source/blender/render')
-rw-r--r-- | source/blender/render/RE_bake.h | 27 | ||||
-rw-r--r-- | source/blender/render/intern/bake.c | 14 | ||||
-rw-r--r-- | source/blender/render/intern/engine.c | 11 |
3 files changed, 31 insertions, 21 deletions
diff --git a/source/blender/render/RE_bake.h b/source/blender/render/RE_bake.h index 3ed41ede006..3463362adb1 100644 --- a/source/blender/render/RE_bake.h +++ b/source/blender/render/RE_bake.h @@ -39,11 +39,23 @@ typedef struct BakeImage { size_t offset; } BakeImage; -typedef struct BakeImages { - BakeImage *data; /* all the images of an object */ - int *lookup; /* lookup table from Material to BakeImage */ - int size; -} BakeImages; +typedef struct BakeTargets { + /* All images of the object. */ + BakeImage *images; + int num_images; + + /* Lookup table from Material number to BakeImage. */ + int *material_to_image; + int num_materials; + + /* Pixel buffer to bake to. */ + float *result; + int num_pixels; + int num_channels; + + /* Baking to non-color data image. */ + bool is_noncolor; +} BakeTargets; typedef struct BakePixel { int primitive_id, object_id; @@ -70,8 +82,7 @@ bool RE_bake_engine(struct Render *re, struct Object *object, const int object_id, const BakePixel pixel_array[], - const BakeImages *bake_images, - const int depth, + const BakeTargets *targets, const eScenePassType pass_type, const int pass_filter, float result[]); @@ -95,7 +106,7 @@ bool RE_bake_pixels_populate_from_objects(struct Mesh *me_low, void RE_bake_pixels_populate(struct Mesh *me, struct BakePixel *pixel_array, const size_t num_pixels, - const struct BakeImages *bake_images, + const struct BakeTargets *targets, const char *uv_layer); void RE_bake_mask_fill(const BakePixel pixel_array[], const size_t num_pixels, char *mask); diff --git a/source/blender/render/intern/bake.c b/source/blender/render/intern/bake.c index 6f5db4986f2..caf81870fac 100644 --- a/source/blender/render/intern/bake.c +++ b/source/blender/render/intern/bake.c @@ -691,7 +691,7 @@ static void bake_differentials(BakeDataZSpan *bd, void RE_bake_pixels_populate(Mesh *me, BakePixel pixel_array[], const size_t num_pixels, - const BakeImages *bake_images, + const BakeTargets *targets, const char *uv_layer) { const MLoopUV *mloopuv; @@ -709,7 +709,7 @@ void RE_bake_pixels_populate(Mesh *me, BakeDataZSpan bd; bd.pixel_array = pixel_array; - bd.zspan = MEM_callocN(sizeof(ZSpan) * bake_images->size, "bake zspan"); + bd.zspan = MEM_callocN(sizeof(ZSpan) * targets->num_images, "bake zspan"); /* initialize all pixel arrays so we know which ones are 'blank' */ for (int i = 0; i < num_pixels; i++) { @@ -717,8 +717,8 @@ void RE_bake_pixels_populate(Mesh *me, pixel_array[i].object_id = 0; } - for (int i = 0; i < bake_images->size; i++) { - zbuf_alloc_span(&bd.zspan[i], bake_images->data[i].width, bake_images->data[i].height); + for (int i = 0; i < targets->num_images; i++) { + zbuf_alloc_span(&bd.zspan[i], targets->images[i].width, targets->images[i].height); } const int tottri = poly_to_tri_count(me->totpoly, me->totloop); @@ -731,13 +731,13 @@ void RE_bake_pixels_populate(Mesh *me, const MPoly *mp = &me->mpoly[lt->poly]; float vec[3][2]; int mat_nr = mp->mat_nr; - int image_id = bake_images->lookup[mat_nr]; + int image_id = targets->material_to_image[mat_nr]; if (image_id < 0) { continue; } - bd.bk_image = &bake_images->data[image_id]; + bd.bk_image = &targets->images[image_id]; bd.primitive_id = i; for (int a = 0; a < 3; a++) { @@ -755,7 +755,7 @@ void RE_bake_pixels_populate(Mesh *me, zspan_scanconvert(&bd.zspan[image_id], (void *)&bd, vec[0], vec[1], vec[2], store_bake_pixel); } - for (int i = 0; i < bake_images->size; i++) { + for (int i = 0; i < targets->num_images; i++) { zbuf_free_span(&bd.zspan[i]); } diff --git a/source/blender/render/intern/engine.c b/source/blender/render/intern/engine.c index 5685911c42e..13faddfcd2f 100644 --- a/source/blender/render/intern/engine.c +++ b/source/blender/render/intern/engine.c @@ -663,8 +663,7 @@ bool RE_bake_engine(Render *re, Object *object, const int object_id, const BakePixel pixel_array[], - const BakeImages *bake_images, - const int depth, + const BakeTargets *targets, const eScenePassType pass_type, const int pass_filter, float result[]) @@ -707,14 +706,14 @@ bool RE_bake_engine(Render *re, type->update(engine, re->main, engine->depsgraph); } - for (int i = 0; i < bake_images->size; i++) { - const BakeImage *image = bake_images->data + i; + for (int i = 0; i < targets->num_images; i++) { + const BakeImage *image = targets->images + i; engine->bake.pixels = pixel_array + image->offset; - engine->bake.result = result + image->offset * depth; + engine->bake.result = result + image->offset * targets->num_channels; engine->bake.width = image->width; engine->bake.height = image->height; - engine->bake.depth = depth; + engine->bake.depth = targets->num_channels; engine->bake.object_id = object_id; type->bake( |