Bug fix #34213 (2)
authorTon Roosendaal <ton@blender.org>
Tue, 12 Feb 2013 15:51:05 +0000 (15:51 +0000)
committerTon Roosendaal <ton@blender.org>
Tue, 12 Feb 2013 15:51:05 +0000 (15:51 +0000)
Adding non-RGBA float buffers as texture crashes MipMap code.
Images with less than 4 channels not supported (yet). Not sure
if we ever should even... normals, Z, vectors, UV, Index, all
don't like downsampling.

source/blender/imbuf/intern/filter.c
source/blender/render/intern/source/imagetexture.c

index 51fee23..9193954 100644 (file)
@@ -506,6 +506,10 @@ void IMB_makemipmap(ImBuf *ibuf, int use_filter)
 
        imb_freemipmapImBuf(ibuf);
        
+       /* no mipmap for non RGBA images */
+       if (ibuf->rect_float && ibuf->channels < 4)
+               return;
+       
        ibuf->miptot = 1;
 
        while (curmap < IB_MIPMAP_LEVELS) {
index 55dadc1..2827f90 100644 (file)
@@ -1042,6 +1042,9 @@ static void image_mipmap_test(Tex *tex, ImBuf *ibuf)
                                        IMB_makemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP);
                                BLI_unlock_thread(LOCK_IMAGE);
                        }
+                       /* if no mipmap could be made, fall back on non-mipmap render */
+                       if (ibuf->mipmap[0] == NULL)
+                               if (tex->imaflag &= ~TEX_MIPMAP);
                }
        }