Fix T44984: wrong texture clamping when applying saturation > 1.0
authorBastien Montagne <montagne29@wanadoo.fr>
Sun, 7 Jun 2015 14:53:56 +0000 (16:53 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Sun, 7 Jun 2015 14:56:58 +0000 (16:56 +0200)
Applying saturation > 1.0 in HSV space easily leads to negative values in RGB space,
so we have to clamp again...

source/blender/render/intern/include/texture.h
source/blender/render/intern/source/render_texture.c

index ebc83984306452cb76e35cad1d9c612d0fbf0726..ed161e186b8ea90a313706d470499037abc8db5f 100644 (file)
                _hsv[1] *= tex->saturation;                                           \
                hsv_to_rgb(_hsv[0], _hsv[1], _hsv[2],                                 \
                           &texres->tr, &texres->tg, &texres->tb);                    \
+               if ((tex->saturation > 1.0f) && !(tex->flag & TEX_NO_CLAMP)) {        \
+                       if (texres->tr < 0.0f) texres->tr= 0.0f;                          \
+                       if (texres->tg < 0.0f) texres->tg= 0.0f;                          \
+                       if (texres->tb < 0.0f) texres->tb= 0.0f;                          \
+               }                                                                     \
        }                                                                         \
 
 struct HaloRen;
index c6a80c822a37163987a6d61ebab2b3318e617922..6acdde6af9c72d9d59c5dc7e66842742fe1fb78a 100644 (file)
@@ -2431,7 +2431,7 @@ void do_material_tex(ShadeInput *shi, Render *re)
 
                                        BKE_image_pool_release_ibuf(ima, ibuf, re->pool);
                                }
-                               
+
                                if (mtex->mapto & MAP_COL) {
                                        float colfac= mtex->colfac*stencilTin;
                                        texture_rgb_blend(&shi->r, tcol, &shi->r, texres.tin, colfac, mtex->blendtype);