[Bf-blender-cvs] [9927849] master: Fix T44984: wrong texture clamping when applying saturation > 1.0

Bastien Montagne noreply at git.blender.org
Sun Jun 7 16:57:40 CEST 2015


Commit: 9927849708ace2657de759fc9b72053b13be9576
Author: Bastien Montagne
Date:   Sun Jun 7 16:53:56 2015 +0200
Branches: master
https://developer.blender.org/rB9927849708ace2657de759fc9b72053b13be9576

Fix T44984: wrong texture clamping when applying saturation > 1.0

Applying saturation > 1.0 in HSV space easily leads to negative values in RGB space,
so we have to clamp again...

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

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

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

diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h
index ebc8398..ed161e1 100644
--- a/source/blender/render/intern/include/texture.h
+++ b/source/blender/render/intern/include/texture.h
@@ -56,6 +56,11 @@
 		_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;
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index c6a80c8..6acdde6 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -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);




More information about the Bf-blender-cvs mailing list