cycles changes:
authorCampbell Barton <ideasman42@gmail.com>
Wed, 4 Jul 2012 11:48:42 +0000 (11:48 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 4 Jul 2012 11:48:42 +0000 (11:48 +0000)
- images that can't be loaded because of the limit are printed in the console.
- textures that can't be found show up as pink (so we know somethings wrong).

intern/cycles/render/image.cpp
intern/cycles/render/image.h
intern/cycles/render/nodes.cpp

index dc20dbdbea2d143a64185356cd27ff2f2917f1cf..1af0972ecf9580317f9e8f0035b229d3d8810429 100644 (file)
@@ -109,8 +109,11 @@ int ImageManager::add_image(const string& filename, bool& is_float)
 
                if(slot == float_images.size()) {
                        /* max images limit reached */
-                       if(float_images.size() == TEX_NUM_FLOAT_IMAGES)
+                       if(float_images.size() == TEX_NUM_FLOAT_IMAGES) {
+                               printf("ImageManager::add_image: byte image limit reached %d, skipping '%s'\n",
+                                      TEX_NUM_IMAGES, filename.c_str());
                                return -1;
+                       }
 
                        float_images.resize(float_images.size() + 1);
                }
@@ -141,8 +144,11 @@ int ImageManager::add_image(const string& filename, bool& is_float)
 
                if(slot == images.size()) {
                        /* max images limit reached */
-                       if(images.size() == TEX_NUM_IMAGES)
+                       if(images.size() == TEX_NUM_IMAGES) {
+                               printf("ImageManager::add_image: byte image limit reached %d, skipping '%s'\n",
+                                      TEX_NUM_IMAGES, filename.c_str());
                                return -1;
+                       }
 
                        images.resize(images.size() + 1);
                }
@@ -353,13 +359,13 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int sl
                        device->tex_free(tex_img);
 
                if(!file_load_float_image(img, tex_img)) {
-                       /* on failure to load, we set a 1x1 pixels black image */
+                       /* on failure to load, we set a 1x1 pixels pink image */
                        float *pixels = (float*)tex_img.resize(1, 1);
 
-                       pixels[0] = 0.0f;
-                       pixels[1] = 0.0f;
-                       pixels[2] = 0.0f;
-                       pixels[3] = 0.0f;
+                       pixels[0] = TEX_IMAGE_MISSING_R;
+                       pixels[1] = TEX_IMAGE_MISSING_G;
+                       pixels[2] = TEX_IMAGE_MISSING_B;
+                       pixels[3] = TEX_IMAGE_MISSING_A;
                }
 
                string name;
@@ -380,13 +386,13 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int sl
                        device->tex_free(tex_img);
 
                if(!file_load_image(img, tex_img)) {
-                       /* on failure to load, we set a 1x1 pixels black image */
+                       /* on failure to load, we set a 1x1 pixels pink image */
                        uchar *pixels = (uchar*)tex_img.resize(1, 1);
 
-                       pixels[0] = 0;
-                       pixels[1] = 0;
-                       pixels[2] = 0;
-                       pixels[3] = 0;
+                       pixels[0] = (TEX_IMAGE_MISSING_R * 255);
+                       pixels[1] = (TEX_IMAGE_MISSING_G * 255);
+                       pixels[2] = (TEX_IMAGE_MISSING_B * 255);
+                       pixels[3] = (TEX_IMAGE_MISSING_A * 255);
                }
 
                string name;
index 2b5e53cabe19ebe3eaf87817a13829cabacb9686..ef046cfcafbe365acd48aa853d8c192678f879b5 100644 (file)
@@ -31,6 +31,12 @@ CCL_NAMESPACE_BEGIN
 #define TEX_IMAGE_MAX                  (TEX_NUM_IMAGES + TEX_NUM_FLOAT_IMAGES)
 #define TEX_IMAGE_FLOAT_START  TEX_NUM_IMAGES
 
+/* color to use when textures are not found */
+#define TEX_IMAGE_MISSING_R 1
+#define TEX_IMAGE_MISSING_G 0
+#define TEX_IMAGE_MISSING_B 1
+#define TEX_IMAGE_MISSING_A 1
+
 class Device;
 class DeviceScene;
 class Progress;
index 0f64d858de0443fda00c5122ef3d27ed0dbd6b43..e4a4b87496487cbe20c38f8ce37f72446986ab23 100644 (file)
@@ -184,10 +184,12 @@ void ImageTextureNode::compile(SVMCompiler& compiler)
                /* image not found */
                if(!color_out->links.empty()) {
                        compiler.add_node(NODE_VALUE_V, color_out->stack_offset);
-                       compiler.add_node(NODE_VALUE_V, make_float3(0, 0, 0));
+                       compiler.add_node(NODE_VALUE_V, make_float3(TEX_IMAGE_MISSING_R,
+                                                                   TEX_IMAGE_MISSING_G,
+                                                                   TEX_IMAGE_MISSING_B));
                }
                if(!alpha_out->links.empty())
-                       compiler.add_node(NODE_VALUE_F, __float_as_int(0.0f), alpha_out->stack_offset);
+                       compiler.add_node(NODE_VALUE_F, __float_as_int(TEX_IMAGE_MISSING_A), alpha_out->stack_offset);
        }
 }
 
@@ -288,10 +290,12 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler)
                /* image not found */
                if(!color_out->links.empty()) {
                        compiler.add_node(NODE_VALUE_V, color_out->stack_offset);
-                       compiler.add_node(NODE_VALUE_V, make_float3(0, 0, 0));
+                       compiler.add_node(NODE_VALUE_V, make_float3(TEX_IMAGE_MISSING_R,
+                                                                   TEX_IMAGE_MISSING_G,
+                                                                   TEX_IMAGE_MISSING_B));
                }
                if(!alpha_out->links.empty())
-                       compiler.add_node(NODE_VALUE_F, __float_as_int(0.0f), alpha_out->stack_offset);
+                       compiler.add_node(NODE_VALUE_F, __float_as_int(TEX_IMAGE_MISSING_A), alpha_out->stack_offset);
        }
 }