[Bf-blender-cvs] [9f90320] master: Fix T36165: blender internal HDR textures with negative values got clamped.

Brecht Van Lommel noreply at git.blender.org
Thu Jan 23 18:50:03 CET 2014


Commit: 9f903208e800d4580314dc03d31e8ae5fea73cdb
Author: Brecht Van Lommel
Date:   Thu Jan 23 18:38:48 2014 +0100
https://developer.blender.org/rB9f903208e800d4580314dc03d31e8ae5fea73cdb

Fix T36165: blender internal HDR textures with negative values got clamped.

For example for vector displacement, you may have an EXR texture that has
negative colors values. Blender clamps these by default, now the Colors panel
for textures has a Clamp option to disable this clamping.

This option affects all texture types and is enabled by default, you need
to disable it if you want negative values to have an influence.

Patch by Fredrik Hansson with modifications by me.

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

M	release/scripts/startup/bl_ui/properties_texture.py
M	source/blender/makesdna/DNA_texture_types.h
M	source/blender/makesrna/intern/rna_texture.c
M	source/blender/render/intern/include/texture.h

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

diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py
index c03ea1c..0093094 100644
--- a/release/scripts/startup/bl_ui/properties_texture.py
+++ b/release/scripts/startup/bl_ui/properties_texture.py
@@ -269,6 +269,9 @@ class TEXTURE_PT_colors(TextureButtonsPanel, Panel):
         col.prop(tex, "contrast")
         col.prop(tex, "saturation")
 
+        col = layout.column()
+        col.prop(tex, "use_clamp", text="Clamp")
+
 # Texture Slot Panels #
 
 
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index fcd0575..a3025a7 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -382,6 +382,7 @@ typedef struct ColorMapping {
 #define TEX_REPEAT_YMIR		256
 #define TEX_FLAG_MASK		( TEX_COLORBAND | TEX_FLIPBLEND | TEX_NEGALPHA | TEX_CHECKER_ODD | TEX_CHECKER_EVEN | TEX_PRV_ALPHA | TEX_PRV_NOR | TEX_REPEAT_XMIR | TEX_REPEAT_YMIR ) 
 #define TEX_DS_EXPAND		512
+#define TEX_NO_CLAMP		1024
 
 /* extend (starts with 1 because of backward comp.) */
 #define TEX_EXTEND		1
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index b453965..37a0ee0 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -2010,6 +2010,11 @@ static void rna_def_texture(BlenderRNA *brna)
 	RNA_def_property_enum_funcs(prop, NULL, "rna_Texture_type_set", NULL);
 	RNA_def_property_ui_text(prop, "Type", "");
 	RNA_def_property_update(prop, 0, "rna_Texture_update");
+
+	prop = RNA_def_property(srna, "use_clamp", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TEX_NO_CLAMP);
+	RNA_def_property_ui_text(prop, "Clamp", "Set negative texture RGB and intensity values to zero, for some uses like displacement this option can be disabled to get the full range");
+	RNA_def_property_update(prop, 0, "rna_Texture_update");
 	
 	prop = RNA_def_property(srna, "use_color_ramp", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_COLORBAND);
diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h
index b23d6b0..0e0337d 100644
--- a/source/blender/render/intern/include/texture.h
+++ b/source/blender/render/intern/include/texture.h
@@ -33,18 +33,22 @@
 #ifndef __TEXTURE_H__
 #define __TEXTURE_H__
 
-#define BRICONT                                                               \
-	texres->tin= (texres->tin-0.5f) * tex->contrast+tex->bright-0.5f;         \
-	if (texres->tin < 0.0f)      texres->tin= 0.0f;                           \
-	else if (texres->tin > 1.0f) texres->tin= 1.0f;                           \
+#define BRICONT                                                           \
+	texres->tin= (texres->tin-0.5f) * tex->contrast+tex->bright-0.5f;     \
+	if(!(tex->flag & TEX_NO_CLAMP)) {                                     \
+		if (texres->tin < 0.0f)      texres->tin= 0.0f;                   \
+		else if (texres->tin > 1.0f) texres->tin= 1.0f;                   \
+	}                                                                     \
 
 #define BRICONTRGB                                                            \
 	texres->tr= tex->rfac*((texres->tr-0.5f)*tex->contrast+tex->bright-0.5f); \
-	if (texres->tr<0.0f) texres->tr= 0.0f;                                    \
 	texres->tg= tex->gfac*((texres->tg-0.5f)*tex->contrast+tex->bright-0.5f); \
-	if (texres->tg<0.0f) texres->tg= 0.0f;                                    \
 	texres->tb= tex->bfac*((texres->tb-0.5f)*tex->contrast+tex->bright-0.5f); \
-	if (texres->tb<0.0f) texres->tb= 0.0f;                                    \
+	if(!(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;                              \
+	}                                                                         \
 	if (tex->saturation != 1.0f) {                                            \
 		float _hsv[3];                                                        \
 		rgb_to_hsv(texres->tr, texres->tg, texres->tb,                        \




More information about the Bf-blender-cvs mailing list