Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/render/image.cpp')
-rw-r--r--intern/cycles/render/image.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index b66d694c82a..f4482e0bb25 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -30,6 +30,16 @@
CCL_NAMESPACE_BEGIN
+/* Some helpers to silence warning in templated function. */
+static bool isfinite(uchar /*value*/)
+{
+ return false;
+}
+static bool isfinite(half /*value*/)
+{
+ return false;
+}
+
ImageManager::ImageManager(const DeviceInfo& info)
{
need_update = true;
@@ -639,6 +649,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];
+ 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) {