146 switch (event->
type) {
189 float *rect,
int channels,
int width,
int height,
int stride)
193 for (
int y = 0; y < height; y++) {
194 float *pixels = rect + size_t(stride) * y *
channels;
195 for (
int x = 0; x < width; x++, pixels +=
channels) {
196 if (
fabsf(pixels[0] - 0.5f) < 1.0f / 255.0f) {
197 pixels[0] = 0.5f + 1e-5f;
199 if (
fabsf(pixels[1] - 0.5f) < 1.0f / 255.0f) {
200 pixels[1] = 0.5f + 1e-5f;
207 const int image_tile_number,
213 const char margin_type,
215 const bool is_noncolor,
216 const bool is_tangent_normal,
217 Mesh const *mesh_eval,
218 char const *uv_layer,
219 const float uv_offset[2])
224 char *mask_buffer =
nullptr;
225 const size_t pixels_num = size_t(width) * size_t(height);
229 iuser.
tile = image_tile_number;
236 if (margin > 0 || !is_clear) {
237 mask_buffer =
static_cast<char *
>(
MEM_callocN(
sizeof(
char) * pixels_num,
"Bake Mask"));
245 const char *from_colorspace;
246 const char *to_colorspace;
257 if (from_colorspace != to_colorspace) {
259 buffer, ibuf->
x, ibuf->
y, ibuf->
channels, from_colorspace, to_colorspace,
false);
262 else if (!is_float && is_tangent_normal) {
322 RE_bake_margin(ibuf, mask_buffer, margin, margin_type, mesh_eval, uv_layer, uv_offset);
350 for (
int i = 0; i < targets->
images_num; i++) {
367 const int margin_type,
369 const bool is_noncolor,
370 const bool is_tangent_normal,
371 Mesh const *mesh_eval,
372 char const *uv_layer,
373 const float uv_offset[2])
375 ImBuf *ibuf =
nullptr;
379 is_float = im_format->
depth > 8;
407 buffer, ibuf->
x, ibuf->
y, ibuf->
channels, from_colorspace, to_colorspace,
false);
409 else if (is_tangent_normal) {
429 char *mask_buffer =
nullptr;
430 const size_t pixels_num = size_t(width) * size_t(height);
432 mask_buffer =
static_cast<char *
>(
MEM_callocN(
sizeof(
char) * pixels_num,
"Bake Mask"));
434 RE_bake_margin(ibuf, mask_buffer, margin, margin_type, mesh_eval, uv_layer, uv_offset);
443 chmod(filepath, S_IRUSR | S_IWUSR);
456 return ELEM(pass_type,
476 if (base ==
nullptr) {
493 if (mesh->faces_num == 0) {
502 "Mesh does not have an active color attribute \"%s\"",
510 reports,
RPT_ERROR,
"No active UV layer found in the object \"%s\"", ob->
id.
name + 2);
514 for (
int i = 0; i < ob->
totcol; i++) {
516 const bNode *node =
nullptr;
517 const int mat_nr = i + 1;
530 "Circular dependency for image \"%s\" from object \"%s\"",
550 "Uninitialized image \"%s\" from object \"%s\"",
561 if (mat !=
nullptr) {
564 "No active image found in material \"%s\" (%d) for object \"%s\"",
572 "No active image found in material slot (%d) for object \"%s\"",
587 const int pass_filter,
609 "Combined bake pass requires Emit, or a light pass with "
610 "Direct or Indirect contributions enabled");
616 "Combined bake pass requires Emit, or a light pass with "
617 "Direct or Indirect contributions enabled");
632 "Bake pass requires Direct, Indirect, or Color contributions to be enabled");
649 const bool is_selected_to_active,
655 if (is_selected_to_active) {
671 "Object \"%s\" is not a mesh or can't be converted to a mesh (Curve, Text, "
672 "Surface or Metaball)",
679 if (tot_objects == 0) {
713 const bool preserve_origindex)
731 int materials_num = ob->
totcol;
733 if (materials_num == 0) {
736 reports,
RPT_ERROR,
"No active image found, add a material or bake to an external file");
743 "No active image found, add a material or bake without the Split Materials option");
756 targets->
images =
nullptr;
758 for (
int i = 0; i < materials_num; i++) {
793 for (
int i = 0; i < targets->
images_num; i++) {
804 bk_image->
width = ibuf->
x;
809 targets->
pixels_num += size_t(ibuf->
x) * size_t(ibuf->
y);
833 for (
int i = 0; i < targets->
images_num; i++) {
837 pixel_array + bk_image->
offset,
857 "Problem saving the bake map internally for object \"%s\"",
863 reports,
RPT_INFO,
"Baking map saved to internal image, save it externally or pack it");
880 for (
int i = 0; i < targets->
images_num; i++) {
916 for (
int i = 0; i < targets->
images_num; i++) {
926 bake->im_format.imtype,
937 if (ob_eval->
mat[i]) {
940 else if (mesh_eval->
mat[i]) {
959 pixel_array + bk_image->
offset,
997 BKE_report(reports,
RPT_ERROR,
"Color attribute baking is only supported for mesh objects");
1010 targets->
images = MEM_cnew<BakeImage>(__func__);
1018 bk_image->
width = mesh->corners_num;
1021 bk_image->
image =
nullptr;
1030 const int *vert_origindex,
1031 const int *poly_origindex,
1032 const int poly_eval,
1033 const int vert_eval)
1037 const int vert_orig = vert_origindex[vert_eval];
1038 const int poly_orig_index = poly_origindex[poly_eval];
1045 const IndexRange orig_face = orig_faces[poly_orig_index];
1046 const int *poly_verts_orig = &orig_corner_verts[orig_face.
start()];
1047 for (
int j = 0; j < orig_face.
size(); ++j) {
1048 if (poly_verts_orig[j] == vert_orig) {
1049 return orig_face.
start() + j;
1065 for (
int i = 0; i < pixels_num; i++) {
1069 pixel->object_id = 0;
1071 pixel->du_dx = 0.0f;
1072 pixel->du_dy = 0.0f;
1073 pixel->dv_dx = 0.0f;
1074 pixel->dv_dy = 0.0f;
1075 pixel->uv[0] = 0.0f;
1076 pixel->uv[1] = 0.0f;
1081 int3 *corner_tris =
static_cast<int3 *
>(
1082 MEM_mallocN(
sizeof(*corner_tris) * corner_tris_num, __func__));
1084 const Span<int> corner_verts = mesh_eval->corner_verts();
1088 {corner_tris, corner_tris_num});
1089 const Span<int> tri_faces = mesh_eval->corner_tri_faces();
1092 const int *vert_origindex =
static_cast<const int *
>(
1094 const int *poly_origindex =
static_cast<const int *
>(
1097 const Span<int> orig_corner_verts = mesh->corner_verts();
1099 for (
int i = 0; i < corner_tris_num; i++) {
1100 const int3 &tri = corner_tris[i];
1101 const int face_i = tri_faces[i];
1103 for (
int j = 0; j < 3; j++) {
1105 const int v = corner_verts[
l];
1108 if (vert_origindex !=
nullptr && poly_origindex !=
nullptr) {
1110 orig_faces, orig_corner_verts, vert_origindex, poly_origindex, face_i,
v);
1118 if (pixel->primitive_id != -1) {
1131 pixel->uv[0] = 1.0f;
1132 pixel->uv[1] = 0.0f;
1135 pixel->uv[0] = 0.0f;
1136 pixel->uv[1] = 1.0f;
1139 pixel->uv[0] = 0.0f;
1140 pixel->uv[1] = 0.0f;
1150 if (channels_num == 4) {
1153 else if (channels_num == 3) {
1158 rgba[0] += result[0];
1159 rgba[1] += result[0];
1160 rgba[2] += result[0];
1167 const bool is_noncolor,
1171 for (
int i = 0; i < num; i++) {
1176 for (
int i = 0; i < num; i++) {
1186 &mesh->id, mesh->active_color_attribute);
1193 const float *result = targets->
result;
1196 const int totvert = mesh->verts_num;
1197 const int totloop = mesh->corners_num;
1203 int *num_loops_for_vertex =
static_cast<int *
>(
1204 MEM_callocN(
sizeof(
int) * mesh->verts_num,
"num_loops_for_vertex"));
1205 memset(mcol, 0,
sizeof(
MPropCol) * mesh->verts_num);
1207 const Span<int> corner_verts = mesh->corner_verts();
1208 for (
int i = 0; i < totloop; i++) {
1209 const int v = corner_verts[i];
1211 num_loops_for_vertex[
v]++;
1215 for (
int i = 0; i < totvert; i++) {
1216 if (num_loops_for_vertex[i] > 0) {
1217 mul_v4_fl(mcol[i].color, 1.0f / num_loops_for_vertex[i]);
1221 if (
BMEditMesh *em = mesh->runtime->edit_mesh.get()) {
1231 memcpy(data, &mcol[i],
sizeof(
MPropCol));
1235 &mcol[i], 1, is_noncolor,
static_cast<MLoopCol *
>(data));
1243 memcpy(active_color_layer->
data, mcol,
sizeof(
MPropCol) * mesh->verts_num);
1247 mcol, totvert, is_noncolor,
static_cast<MLoopCol *
>(active_color_layer->
data));
1256 if (
BMEditMesh *em = mesh->runtime->edit_mesh.get()) {
1274 memcpy(data, &color,
sizeof(
MPropCol));
1278 &color, 1, is_noncolor,
static_cast<MLoopCol *
>(data));
1287 for (
int i = 0; i < mesh->corners_num; i++) {
1294 for (
int i = 0; i < mesh->corners_num; i++) {
1375 bkr, targets, ob, ob_eval, mesh_eval, pixel_array, reports);
1412 Object *ob_cage =
nullptr;
1413 Object *ob_cage_eval =
nullptr;
1414 Object *ob_low_eval =
nullptr;
1417 int tot_highpoly = 0;
1419 Mesh *me_low_eval =
nullptr;
1420 Mesh *me_cage_eval =
nullptr;
1423 int mmd_flags_low = 0;
1444 "No UV layer named \"%s\" found in the object \"%s\"",
1457 if (ob_iter == ob_low) {
1465 ob_cage =
static_cast<Object *
>(
1468 if (ob_cage ==
nullptr || ob_cage->
type !=
OB_MESH) {
1487 mmd_flags_low = mmd_low->
flags;
1506 pixel_array_low =
static_cast<BakePixel *
>(
1523 "Invalid cage object, the cage mesh must have the same number "
1524 "of faces as the active object");
1529 bool is_changed =
false;
1571 if (ob_iter == ob_low) {
1576 highpoly[i].
ob = ob_iter;
1584 copy_m4_m4(highpoly[i].obmat, highpoly[i].ob->object_to_world().ptr());
1594 if (ob_cage !=
nullptr) {
1603 pixel_array_high =
static_cast<BakePixel *
>(
1616 ob_low_eval->object_to_world().ptr(),
1617 (ob_cage ? ob_cage->object_to_world().ptr() : ob_low_eval->object_to_world().ptr()),
1625 for (i = 0; i < tot_highpoly; i++) {
1637 reports,
RPT_ERROR,
"Error baking from object \"%s\"", highpoly[i].ob->id.name + 2);
1698 ob_low_eval->object_to_world().ptr());
1702 Mesh *me_nores =
nullptr;
1711 md->
mode &= ~eModifierMode_Render;
1722 (me_nores) ? me_nores : me_low_eval,
1724 ob_low_eval->object_to_world().ptr());
1745 bkr, &targets, ob_low, ob_low_eval, me_low_eval, pixel_array_low, reports))
1759 for (
int i = 0; i < tot_highpoly; i++) {
1760 if (highpoly[i].mesh !=
nullptr) {
1768 mmd_low->
flags = mmd_flags_low;
1771 if (pixel_array_low) {
1775 if (pixel_array_high) {
1781 if (me_low_eval !=
nullptr) {
1785 if (me_cage_eval !=
nullptr) {
1871 G.is_rendering =
true;
1882 G.is_rendering =
false;
1895 G.is_rendering =
false;
1920 G.is_rendering =
false;
1993 G.is_rendering =
false;
2044 op->
ptr, prop, (
bake->cage_object) ?
bake->cage_object->id.name + 2 :
"");
2142 G.is_rendering =
true;
2161 ot->
description =
"Bake image textures of selected objects";
2176 "Type of pass to bake, some of them may not be supported by the current render engine");
2182 "Filter to combined, diffuse, glossy, transmission and subsurface passes");
2189 "Image filepath to use when saving externally");
2196 "Horizontal dimension of the baking map (external only)",
2205 "Vertical dimension of the baking map (external only)",
2214 "Extends the baked result as a post process filter",
2222 "Which algorithm to use to generate the margin");
2224 "use_selected_to_active",
2226 "Selected to Active",
2227 "Bake shading on the surface of selected objects to the active object");
2234 "The maximum ray distance for matching points between the active and selected "
2235 "objects. If zero, there is no limit",
2244 "Inflate the active object by the specified distance for baking. This helps "
2245 "matching to points nearer to the outside of the selected object meshes",
2253 "Object to use as cage, instead of calculating the cage from the active object "
2254 "with cage extrusion");
2260 "Choose normal space for baking");
2266 "Axis to bake in red channel");
2273 "Axis to bake in green channel");
2280 "Axis to bake in blue channel");
2287 "Where to output the baked map");
2293 "Where to save baked image textures");
2298 "Clear images before baking (only for internal saving)");
2302 "use_split_materials",
2305 "Split baked maps per material, using material name in output file (external only)");
2307 "use_automatic_name",
2310 "Automatically name the output file with the pass type");
2316 "UV layer to override active");
const struct CustomDataLayer * BKE_id_attributes_color_find(const struct ID *id, const char *name)
blender::bke::AttrDomain BKE_attribute_domain(const AttributeOwner &owner, const struct CustomDataLayer *layer)
void BKE_callback_exec_id(Main *bmain, ID *id, eCbEvent evt)
@ BKE_CB_EVT_OBJECT_BAKE_CANCEL
@ BKE_CB_EVT_OBJECT_BAKE_COMPLETE
@ BKE_CB_EVT_OBJECT_BAKE_PRE
bScreen * CTX_wm_screen(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
bool CTX_data_selected_objects(const bContext *C, blender::Vector< PointerRNA > *list)
Main * CTX_data_main(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
int CustomData_get_named_layer(const CustomData *data, eCustomDataType type, blender::StringRef name)
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
int CustomData_get_active_layer_index(const CustomData *data, eCustomDataType type)
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
void BKE_image_mark_dirty(Image *image, ImBuf *ibuf)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
void BKE_image_get_tile_uv(const Image *ima, const int tile_number, float r_uv[2])
void BKE_imageuser_default(ImageUser *iuser)
void BKE_image_free_gputextures(Image *ima)
bool BKE_imbuf_write(ImBuf *ibuf, const char *filepath, const ImageFormatData *imf)
void BKE_image_partial_update_mark_full_update(Image *image)
Mark the whole image to be updated.
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
void BKE_main_id_tag_idcode(Main *mainvar, short type, int tag, bool value)
void BKE_id_free(Main *bmain, void *idv)
const char * BKE_main_blendfile_path(const Main *bmain) ATTR_NONNULL()
General operations, lookup, etc. for materials.
struct Material * BKE_object_material_get(struct Object *ob, short act)
Mesh * BKE_mesh_new_from_object(Depsgraph *depsgraph, Object *object, bool preserve_all_data_layers, bool preserve_origindex)
ModifierData * BKE_modifiers_findby_type(const Object *ob, ModifierType type)
void BKE_modifier_free(ModifierData *md)
General operations, lookup, etc. for blender objects.
void BKE_object_eval_reset(Object *ob_eval)
void BKE_object_handle_data_update(Depsgraph *depsgraph, Scene *scene, Object *ob)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
void BKE_scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain)
ScrArea * BKE_screen_find_big_area(const bScreen *screen, int spacetype, short min)
File and directory operations.
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4])
MINLINE int poly_to_tri_count(int poly_count, int corner_count)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
bool is_negative_m4(const float mat[4][4])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
MINLINE void mul_v4_fl(float r[4], float f)
MINLINE void add_v4_v4(float r[4], const float a[4])
MINLINE void zero_v4(float r[4])
MINLINE void add_v3_v3(float r[3], const float a[3])
bool bool BLI_path_suffix(char *path, size_t path_maxncpy, const char *suffix, const char *sep) ATTR_NONNULL(1
#define SNPRINTF(dst, format,...)
#define BLT_I18NCONTEXT_COLOR
void DEG_id_tag_update(ID *id, unsigned int flags)
Depsgraph * DEG_graph_new(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
void DEG_graph_free(Depsgraph *graph)
void DEG_graph_build_from_view_layer(Depsgraph *graph)
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
#define MAX_CUSTOMDATA_LAYER_NAME
#define MAX_CUSTOMDATA_LAYER_NAME_NO_PREFIX
@ BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT
@ eModifierType_EdgeSplit
Object is a sort of wrapper for general info.
@ R_BAKE_TARGET_VERTEX_COLORS
@ R_BAKE_TARGET_IMAGE_TEXTURES
@ R_BAKE_PASS_FILTER_DIFFUSE
@ R_BAKE_PASS_FILTER_NONE
@ R_BAKE_PASS_FILTER_COLOR
@ R_BAKE_PASS_FILTER_SUBSURFACE
@ R_BAKE_PASS_FILTER_INDIRECT
@ R_BAKE_PASS_FILTER_DIRECT
@ R_BAKE_PASS_FILTER_GLOSSY
@ R_BAKE_PASS_FILTER_EMIT
@ R_BAKE_PASS_FILTER_TRANSM
@ SCE_PASS_SUBSURFACE_COLOR
void ED_mesh_split_faces(Mesh *mesh)
bool ED_operator_object_active_editable_mesh(bContext *C)
bool ED_object_get_active_image(Object *ob, int mat_nr, Image **r_ima, ImageUser **r_iuser, const bNode **r_node, const bNodeTree **r_ntree)
const char * IMB_colormanagement_role_colorspace_name_get(int role)
@ COLOR_ROLE_SCENE_LINEAR
const char * IMB_colormanagement_get_rect_colorspace(ImBuf *ibuf)
void IMB_colormanagement_transform(float *buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace, bool predivide)
const char * IMB_colormanagement_get_float_colorspace(ImBuf *ibuf)
void IMB_buffer_float_from_float_mask(float *rect_to, const float *rect_from, int channels_from, int width, int height, int stride_to, int stride_from, char *mask)
void IMB_buffer_float_from_float(float *rect_to, const float *rect_from, int channels_from, int profile_to, int profile_from, bool predivide, int width, int height, int stride_to, int stride_from)
void imb_freemipmapImBuf(ImBuf *ibuf)
void IMB_buffer_byte_from_float_mask(unsigned char *rect_to, const float *rect_from, int channels_from, float dither, bool predivide, int width, int height, int stride_to, int stride_from, char *mask)
void IMB_buffer_byte_from_float(unsigned char *rect_to, const float *rect_from, int channels_from, float dither, int profile_to, int profile_from, bool predivide, int width, int height, int stride_to, int stride_from)
Contains defines and structs used throughout the imbuf module.
#define IB_PROFILE_LINEAR_RGB
@ IB_DISPLAY_BUFFER_INVALID
Read Guarded memory(de)allocation.
#define MEM_recallocN(vmemh, len)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a producing a negative Combine Generate a color from its and blue channels(Deprecated)") DefNode(ShaderNode
@ WM_JOB_TYPE_OBJECT_BAKE
void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[], const size_t pixels_num, const int depth, float result[], Mesh *mesh, const eBakeNormalSwizzle normal_swizzle[3], const float mat[4][4])
int RE_pass_depth(const eScenePassType pass_type)
void RE_bake_ibuf_clear(Image *image, const bool is_tangent)
void RE_bake_normal_world_to_world(const BakePixel pixel_array[], const size_t pixels_num, const int depth, float result[], const eBakeNormalSwizzle normal_swizzle[3])
void RE_bake_pixels_populate(Mesh *mesh, BakePixel pixel_array[], const size_t pixels_num, const BakeTargets *targets, const char *uv_layer)
void RE_bake_margin(ImBuf *ibuf, char *mask, const int margin, const char margin_type, const Mesh *mesh, char const *uv_layer, const float uv_offset[2])
void RE_bake_normal_world_to_object(const BakePixel pixel_array[], const size_t pixels_num, const int depth, float result[], Object *ob, const eBakeNormalSwizzle normal_swizzle[3])
bool RE_bake_pixels_populate_from_objects(Mesh *me_low, BakePixel pixel_array_from[], BakePixel pixel_array_to[], BakeHighPolyData highpoly[], const int tot_highpoly, const size_t pixels_num, const bool is_custom_cage, const float cage_extrusion, const float max_ray_distance, const float mat_low[4][4], const float mat_cage[4][4], Mesh *me_cage)
void RE_bake_mask_fill(const BakePixel pixel_array[], const size_t pixels_num, char *mask)
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert * v
static AttributeOwner from_id(ID *id)
constexpr int64_t size() const
constexpr int64_t start() const
constexpr bool is_empty() const
input_tx image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "preview_img") .compute_source("compositor_compute_preview.glsl") .do_static_compilation(true)
const Depsgraph * depsgraph
struct ImBuf * IMB_allocImBuf(unsigned int, unsigned int, unsigned char, unsigned int)
void IMB_freeImBuf(ImBuf *)
bool RE_bake_engine(Render *re, Depsgraph *depsgraph, Object *object, const int object_id, const BakePixel pixel_array[], const BakeTargets *targets, const eScenePassType pass_type, const int pass_filter, float result[])
bool RE_bake_has_engine(const Render *re)
void RE_bake_engine_set_engine_parameters(Render *re, Main *bmain, Scene *scene)
ccl_global const KernelWorkTile * tile
void *(* MEM_mallocN)(size_t len, const char *str)
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
#define unit_float_to_uchar_clamp_v4(v1, v2)
void corner_tris_calc(Span< float3 > vert_positions, OffsetIndices< int > faces, Span< int > corner_verts, MutableSpan< int3 > corner_tris)
bool node_is_connected_to_output(const bNodeTree *ntree, const bNode *node)
static int bake(const BakeAPIRender *bkr, Object *ob_low, const Span< PointerRNA > selected_objects, ReportList *reports)
static void convert_float_color_to_byte_color(const MPropCol *float_colors, const int num, const bool is_noncolor, MLoopCol *byte_colors)
static bool bake_objects_check(Main *bmain, const Scene *scene, ViewLayer *view_layer, Object *ob, Span< PointerRNA > selected_objects, ReportList *reports, const bool is_selected_to_active, const eBakeTarget target)
static Mesh * bake_mesh_new_from_object(Depsgraph *depsgraph, Object *object, const bool preserve_origindex)
static bool bake_targets_init(const BakeAPIRender *bkr, BakeTargets *targets, Object *ob, Object *ob_eval, ReportList *reports)
static void bake_startjob(void *bkv, wmJobWorkerStatus *worker_status)
static void bake_targets_populate_pixels_color_attributes(BakeTargets *targets, Object *ob, Mesh *mesh_eval, BakePixel *pixel_array)
static void bake_targets_refresh(BakeTargets *targets)
static void bake_job_complete(void *bkv)
static int find_original_loop(const OffsetIndices< int > orig_faces, const Span< int > orig_corner_verts, const int *vert_origindex, const int *poly_origindex, const int poly_eval, const int vert_eval)
void OBJECT_OT_bake(wmOperatorType *ot)
static bool bake_object_check(const Scene *scene, ViewLayer *view_layer, Object *ob, const eBakeTarget target, ReportList *reports)
static bool bake_break(void *)
static void bake_job_canceled(void *bkv)
static bool bake_targets_output_internal(const BakeAPIRender *bkr, BakeTargets *targets, Object *ob, BakePixel *pixel_array, ReportList *reports, Mesh *mesh_eval)
static void bake_update_image(ScrArea *area, Image *image)
static bool write_internal_bake_pixels(Image *image, const int image_tile_number, BakePixel pixel_array[], float *buffer, const int width, const int height, const int margin, const char margin_type, const bool is_clear, const bool is_noncolor, const bool is_tangent_normal, Mesh const *mesh_eval, char const *uv_layer, const float uv_offset[2])
static void bake_targets_populate_pixels(const BakeAPIRender *bkr, BakeTargets *targets, Object *ob, Mesh *mesh_eval, BakePixel *pixel_array)
static void bake_freejob(void *bkv)
static void bake_init_api_data(wmOperator *op, bContext *C, BakeAPIRender *bkr)
static int bake_modal(bContext *C, wmOperator *, const wmEvent *event)
static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
static void bias_tangent_normal_pixels(float *rect, int channels, int width, int height, int stride)
static bool bake_pass_filter_check(eScenePassType pass_type, const int pass_filter, ReportList *reports)
static bool bake_targets_init_image_textures(const BakeAPIRender *bkr, BakeTargets *targets, Object *ob, ReportList *reports)
static bool bake_targets_output(const BakeAPIRender *bkr, BakeTargets *targets, Object *ob, Object *ob_eval, Mesh *mesh_eval, BakePixel *pixel_array, ReportList *reports)
static void bake_targets_free(BakeTargets *targets)
static bool bake_targets_init_vertex_colors(Main *bmain, BakeTargets *targets, Object *ob, ReportList *reports)
static bool write_external_bake_pixels(const char *filepath, BakePixel pixel_array[], float *buffer, const int width, const int height, const int margin, const int margin_type, ImageFormatData const *im_format, const bool is_noncolor, const bool is_tangent_normal, Mesh const *mesh_eval, char const *uv_layer, const float uv_offset[2])
static bool bake_targets_init_internal(const BakeAPIRender *bkr, BakeTargets *targets, Object *ob, ReportList *reports)
static bool bake_targets_init_external(const BakeAPIRender *bkr, BakeTargets *targets, Object *ob, ReportList *reports)
static void bake_progress_update(void *bjv, float progress)
static void bake_set_props(wmOperator *op, Scene *scene)
static void bake_targets_clear(Main *bmain, const bool is_tangent)
static bool bake_targets_output_external(const BakeAPIRender *bkr, BakeTargets *targets, Object *ob, Object *ob_eval, Mesh *mesh_eval, BakePixel *pixel_array, ReportList *reports)
static int bake_invoke(bContext *C, wmOperator *op, const wmEvent *)
bool editmode_load(Main *bmain, Object *obedit)
static int bake_exec(bContext *C, wmOperator *op)
static bool is_noncolor_pass(eScenePassType pass_type)
static void bake_result_add_to_rgba(float rgba[4], const float *result, const int channels_num)
bool RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **r_identifier)
void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
int RNA_int_get(PointerRNA *ptr, const char *name)
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
float RNA_float_get(PointerRNA *ptr, const char *name)
void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_string_file_path(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
const EnumPropertyItem rna_enum_bake_pass_type_items[]
const EnumPropertyItem rna_enum_normal_swizzle_items[]
const EnumPropertyItem rna_enum_bake_pass_filter_type_items[]
const EnumPropertyItem rna_enum_bake_save_mode_items[]
const EnumPropertyItem rna_enum_bake_margin_type_items[]
const EnumPropertyItem rna_enum_bake_target_items[]
const EnumPropertyItem rna_enum_normal_space_items[]
void RE_progress_cb(Render *re, void *handle, void(*f)(void *handle, float))
void RE_test_break_cb(Render *re, void *handle, bool(*f)(void *handle))
Render * RE_NewSceneRender(const Scene *scene)
void RE_SetReports(Render *re, ReportList *reports)
struct Image ** material_to_image
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
ImBuf * mipmap[IMB_MIPMAP_LEVELS]
struct ModifierData * next
Vector< PointerRNA > selected_objects
eBakeNormalSwizzle normal_swizzle[3]
char uv_layer[MAX_CUSTOMDATA_LAYER_NAME]
char custom_cage[MAX_NAME]
bool is_selected_to_active
eBakeMarginType margin_type
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
void WM_cursor_wait(bool val)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_jobs_timer(wmJob *wm_job, double time_step, uint note, uint endnote)
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
wmJob * WM_jobs_get(wmWindowManager *wm, wmWindow *win, const void *owner, const char *name, const eWM_JobFlag flag, const eWM_JobType job_type)
void WM_jobs_callbacks_ex(wmJob *wm_job, wm_jobs_start_callback startjob, void(*initjob)(void *), void(*update)(void *), void(*endjob)(void *), void(*completed)(void *), void(*canceled)(void *))
bool WM_jobs_test(const wmWindowManager *wm, const void *owner, int job_type)
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *customdata))