[Bf-blender-cvs] [dd04f54e845] master: Fix inaccuracy when storing material ID pass in half float multilayer EXR.

Brecht Van Lommel noreply at git.blender.org
Thu Nov 23 17:40:58 CET 2017


Commit: dd04f54e845e976e525e17a4bfa91714a2bca341
Author: Brecht Van Lommel
Date:   Thu Nov 23 16:27:22 2017 +0100
Branches: master
https://developer.blender.org/rBdd04f54e845e976e525e17a4bfa91714a2bca341

Fix inaccuracy when storing material ID pass in half float multilayer EXR.

These and other non-RGB passes should always be stored as full float, the
precision loss is too unpredictable.

Related to T53381, but that one is about file output nodes where we don't
know the type of data being saved currently.

===================================================================

M	source/blender/render/intern/source/render_result.c

===================================================================

diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index 9ad5d73fc55..88ccb9452ba 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -925,6 +925,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];
@@ -940,10 +951,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);
 			}
 		}
 	}



More information about the Bf-blender-cvs mailing list