[Bf-blender-cvs] [1d49205b1a1] master: Fix T51529: Black boxes on a denoising render when using a .exr image as a environmental texture

Sergey Sharybin noreply at git.blender.org
Wed May 17 15:30:57 CEST 2017


Commit: 1d49205b1a1d39bdc47ac85ce8ec70a773a1a7e0
Author: Sergey Sharybin
Date:   Wed May 17 15:29:47 2017 +0200
Branches: master
https://developer.blender.org/rB1d49205b1a1d39bdc47ac85ce8ec70a773a1a7e0

Fix T51529: Black boxes on a denoising render when using a .exr image as a environmental texture

It is caused by NaN value in the input texture. Now we check for all the pixels
having proper finite values.

Should also help here in the studio,

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

M	intern/cycles/render/image.cpp

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

diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index b66d694c82a..e242192e9e0 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -639,6 +639,37 @@ bool ImageManager::file_load_image(Image *img,
 			}
 		}
 	}
+	/* Make sure we don't have buggy values. */
+	if(FileFormat == TypeDesc::FLOAT) {
+		/* For RGBA buffers we put all channels to 0 if either of them is not
+		 * finite. This way we avoid possible artifacts caused by fully changed
+		 * hue.
+		 */
+		if(is_rgba) {
+			for(size_t i = 0; i < num_pixels; i += 4) {
+				StorageType *pixel = &pixels[i*4];
+				if(!isfinite(pixel[0]) ||
+				   !isfinite(pixel[1]) ||
+				   !isfinite(pixel[2]) ||
+				   !isfinite(pixel[3]))
+				{
+					pixel[0] = 0;
+					pixel[1] = 0;
+					pixel[2] = 0;
+					pixel[3] = 0;
+				}
+			}
+		}
+		else {
+			for(size_t i = 0; i < num_pixels; ++i) {
+				StorageType *pixel = &pixels[i*4];
+				if(!isfinite(pixel[0])) {
+					pixel[0] = 0;
+				}
+			}
+		}
+	}
+	/* Scale image down if needed. */
 	if(pixels_storage.size() > 0) {
 		float scale_factor = 1.0f;
 		while(max_size * scale_factor > texture_limit) {




More information about the Bf-blender-cvs mailing list