[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52683] trunk/blender/source/blender/ compositor/operations/COM_MapRangeOperation.cpp: Map Range: added the same infinity clamping for Z buffer as normalize node.

Sergey Sharybin sergey.vfx at gmail.com
Fri Nov 30 14:17:20 CET 2012


Revision: 52683
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52683
Author:   nazgul
Date:     2012-11-30 13:17:19 +0000 (Fri, 30 Nov 2012)
Log Message:
-----------
Map Range: added the same infinity clamping for Z buffer as normalize node.

Think should be pretty much harmless since if this node was used for buffers
with infinities it already showed artifacts. Now it should be more useful for
mapping Z buffers.

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/operations/COM_MapRangeOperation.cpp

Modified: trunk/blender/source/blender/compositor/operations/COM_MapRangeOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_MapRangeOperation.cpp	2012-11-30 12:48:30 UTC (rev 52682)
+++ trunk/blender/source/blender/compositor/operations/COM_MapRangeOperation.cpp	2012-11-30 13:17:19 UTC (rev 52683)
@@ -43,6 +43,9 @@
 	this->m_destMaxOperation = this->getInputSocketReader(4);
 }
 
+/* The code below assumes all data is inside range +- this, and that input buffer is single channel */
+#define BLENDER_ZMAX 10000.0f
+
 void MapRangeOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
 {
 	float inputs[8]; /* includes the 5 inputs + 3 pads */
@@ -61,10 +64,16 @@
 	source_max = inputs[2];
 	dest_min = inputs[3];
 	dest_max = inputs[4];
-	
-	value = (value - source_min) / (source_max - source_min);
-	value = dest_min + value * (dest_max - dest_min);
 
+	if (value >= -BLENDER_ZMAX && value <= BLENDER_ZMAX) {
+		value = (value - source_min) / (source_max - source_min);
+		value = dest_min + value * (dest_max - dest_min);
+	}
+	else if (value > BLENDER_ZMAX)
+		value = dest_max;
+	else
+		value = dest_min;
+
 	if (this->m_useClamp) {
 		if (dest_max > dest_min) {
 			CLAMP(value, dest_min, dest_max);




More information about the Bf-blender-cvs mailing list