Merge branch 'master' into blender2.8
[blender.git] / source / blender / render / intern / source / render_result.c
index 53169c256a944b9a21c305dad40a4016ae0369ad..0e7f35fbca35757f292b2bb19536b4b77c450080 100644 (file)
@@ -921,6 +921,17 @@ bool RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *fil
                                }
                        }
 
+                       /* We only store RGBA passes as half float, for
+                        * others precision loss can be problematic. */
+                       bool pass_half_float = half_float &&
+                                              (STREQ(rp->chan_id, "RGB") ||
+                                               STREQ(rp->chan_id, "RGBA") ||
+                                               STREQ(rp->chan_id, "R") ||
+                                               STREQ(rp->chan_id, "G") ||
+                                               STREQ(rp->chan_id, "B") ||
+                                               STREQ(rp->chan_id, "A"));
+
+
                        for (int a = 0; a < rp->channels; a++) {
                                /* Save Combined as RGBA if single layer save. */
                                char passname[EXR_PASS_MAXNAME];
@@ -936,10 +947,9 @@ bool RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *fil
                                        layname[0] = '\0';
                                }
 
-                               /* Add channel. */
                                IMB_exr_add_channel(exrhandle, layname, passname, viewname,
                                                    rp->channels, rp->channels * rr->rectx, rp->rect + a,
-                                                   STREQ(rp->name, RE_PASSNAME_Z) ? false : half_float);
+                                                   pass_half_float);
                        }
                }
        }