Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/image_save.cc
| Show First 20 Lines • Show All 718 Lines • ▼ Show 20 Lines | bool BKE_image_render_write_exr(ReportList *reports, | ||||
| const bool save_as_render, | const bool save_as_render, | ||||
| const char *view, | const char *view, | ||||
| int layer) | int layer) | ||||
| { | { | ||||
| void *exrhandle = IMB_exr_get_handle(); | void *exrhandle = IMB_exr_get_handle(); | ||||
| const bool half_float = (imf && imf->depth == R_IMF_CHAN_DEPTH_16); | const bool half_float = (imf && imf->depth == R_IMF_CHAN_DEPTH_16); | ||||
| const bool multi_layer = !(imf && imf->imtype == R_IMF_IMTYPE_OPENEXR); | const bool multi_layer = !(imf && imf->imtype == R_IMF_IMTYPE_OPENEXR); | ||||
| const bool write_z = !multi_layer && (imf && (imf->flag & R_IMF_FLAG_ZBUF)); | const bool write_z = !multi_layer && (imf && (imf->flag & R_IMF_FLAG_ZBUF)); | ||||
| const int channels = (imf && imf->planes == R_IMF_PLANES_RGB) ? 3 : 4; | |||||
| Vector<float *> tmp_output_rects; | Vector<float *> tmp_output_rects; | ||||
| /* Write first layer if not multilayer and no layer was specified. */ | /* Write first layer if not multilayer and no layer was specified. */ | ||||
| if (!multi_layer && layer == -1) { | if (!multi_layer && layer == -1) { | ||||
| layer = 0; | layer = 0; | ||||
| } | } | ||||
| /* First add views since IMB_exr_add_channel checks number of views. */ | /* First add views since IMB_exr_add_channel checks number of views. */ | ||||
| Show All 27 Lines | LISTBASE_FOREACH (RenderView *, rview, &rr->views) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| float *output_rect = (save_as_render) ? | float *output_rect = (save_as_render) ? | ||||
| image_exr_from_scene_linear_to_output( | image_exr_from_scene_linear_to_output( | ||||
| rview->rectf, rr->rectx, rr->recty, 4, imf, tmp_output_rects) : | rview->rectf, rr->rectx, rr->recty, 4, imf, tmp_output_rects) : | ||||
| rview->rectf; | rview->rectf; | ||||
| for (int a = 0; a < 4; a++) { | for (int a = 0; a < channels; a++) { | ||||
| char passname[EXR_PASS_MAXNAME]; | char passname[EXR_PASS_MAXNAME]; | ||||
| char layname[EXR_PASS_MAXNAME]; | char layname[EXR_PASS_MAXNAME]; | ||||
| /* "A" is not used if only "RGB" channels are output. */ | |||||
| const char *chan_id = "RGBA"; | const char *chan_id = "RGBA"; | ||||
| if (multi_layer) { | if (multi_layer) { | ||||
| RE_render_result_full_channel_name(passname, nullptr, "Combined", nullptr, chan_id, a); | RE_render_result_full_channel_name(passname, nullptr, "Combined", nullptr, chan_id, a); | ||||
| BLI_strncpy(layname, "Composite", sizeof(layname)); | BLI_strncpy(layname, "Composite", sizeof(layname)); | ||||
| } | } | ||||
| else { | else { | ||||
| passname[0] = chan_id[a]; | passname[0] = chan_id[a]; | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | LISTBASE_FOREACH (RenderPass *, rp, &rl->passes) { | ||||
| /* Color-space conversion only happens on RGBA passes. */ | /* Color-space conversion only happens on RGBA passes. */ | ||||
| float *output_rect = | float *output_rect = | ||||
| (save_as_render && pass_RGBA) ? | (save_as_render && pass_RGBA) ? | ||||
| image_exr_from_scene_linear_to_output( | image_exr_from_scene_linear_to_output( | ||||
| rp->rect, rr->rectx, rr->recty, rp->channels, imf, tmp_output_rects) : | rp->rect, rr->rectx, rr->recty, rp->channels, imf, tmp_output_rects) : | ||||
| rp->rect; | rp->rect; | ||||
| for (int a = 0; a < rp->channels; a++) { | for (int a = 0; a < std::min(channels, rp->channels); a++) { | ||||
| /* Save Combined as RGBA if single layer save. */ | /* Save Combined as RGBA or RGB if single layer save. */ | ||||
| char passname[EXR_PASS_MAXNAME]; | char passname[EXR_PASS_MAXNAME]; | ||||
| char layname[EXR_PASS_MAXNAME]; | char layname[EXR_PASS_MAXNAME]; | ||||
| if (multi_layer) { | if (multi_layer) { | ||||
| RE_render_result_full_channel_name(passname, nullptr, rp->name, nullptr, rp->chan_id, a); | RE_render_result_full_channel_name(passname, nullptr, rp->name, nullptr, rp->chan_id, a); | ||||
| BLI_strncpy(layname, rl->name, sizeof(layname)); | BLI_strncpy(layname, rl->name, sizeof(layname)); | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 204 Lines • Show Last 20 Lines | |||||