From 9d796df4f6376809f14ca0dd0484f63df9c72494 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 19 Jun 2015 13:00:18 +0200 Subject: Support half float file format storage for Multilayer EXR Quite straightforward implementation -- all the conversion magic is happening in IMB_exr_write_channels() and remained changes are only needed to pass information whether channels is to be converted to half float or not. Regular file output will use full-float for Z pass, which matches behavior of the single layer EXR files. But when saving happens with File Output node then all the passes are respecting half float settings because it's not possible to distinguish whether we're saving Z pass or not. Reviewers: juicyfruit, campbellbarton Reviewed By: campbellbarton Subscribers: maxon, effstops, fsiddi Differential Revision: https://developer.blender.org/D1353 --- .../blender/render/intern/source/render_result.c | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'source/blender/render') diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index ddd9859ce54..2af6a383145 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -502,7 +502,7 @@ static RenderPass *render_layer_add_pass(RenderResult *rr, RenderLayer *rl, int if (rl->exrhandle) { int a; for (a = 0; a < channels; a++) - IMB_exr_add_channel(rl->exrhandle, rl->name, name_from_passtype(passtype, a), viewname, 0, 0, NULL); + IMB_exr_add_channel(rl->exrhandle, rl->name, name_from_passtype(passtype, a), viewname, 0, 0, NULL, false); } else { float *rect; @@ -1038,6 +1038,7 @@ bool RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *fil size_t width, height; const bool is_mono = view && !multiview; + const bool use_half_float = (imf->depth == R_IMF_CHAN_DEPTH_16); width = rr->rectx; height = rr->recty; @@ -1049,12 +1050,17 @@ bool RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *fil IMB_exr_add_view(exrhandle, rview->name); if (rview->rectf) { - for (a = 0; a < 4; a++) + for (a = 0; a < 4; a++) { IMB_exr_add_channel(exrhandle, "", RGBAZ[a], - rview->name, 4, 4 * width, rview->rectf + a); - if (rview->rectz) + rview->name, 4, 4 * width, rview->rectf + a, + use_half_float); + } + if (rview->rectz) { + /* Z pass is always stored as float. */ IMB_exr_add_channel(exrhandle, "", RGBAZ[4], - rview->name, 1, width, rview->rectz); + rview->name, 1, width, rview->rectz, + false); + } } } } @@ -1074,9 +1080,11 @@ bool RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *fil IMB_exr_add_view(exrhandle, rview->name); if (rview->rectf) { - for (a = 0; a < 4; a++) + for (a = 0; a < 4; a++) { IMB_exr_add_channel(exrhandle, "Composite", name_from_passtype(SCE_PASS_COMBINED, a), - chan_view, 4, 4 * width, rview->rectf + a); + chan_view, 4, 4 * width, rview->rectf + a, + use_half_float); + } } } @@ -1099,14 +1107,15 @@ bool RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *fil } for (a = 0; a < xstride; a++) { - if (rpass->passtype) { IMB_exr_add_channel(exrhandle, rl->name, name_from_passtype(rpass->passtype, a), chan_view, - xstride, xstride * width, rpass->rect + a); + xstride, xstride * width, rpass->rect + a, + rpass->passtype == SCE_PASS_Z ? false : use_half_float); } else { IMB_exr_add_channel(exrhandle, rl->name, make_pass_name(rpass, a), chan_view, - xstride, xstride * width, rpass->rect + a); + xstride, xstride * width, rpass->rect + a, + use_half_float); } } } -- cgit v1.2.3