Normalize node: clamp infinities to 0/1 (depending on sign)
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 30 Nov 2012 12:48:30 +0000 (12:48 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 30 Nov 2012 12:48:30 +0000 (12:48 +0000)
The same behavior was in old compositor system and it makes more sense
when you're normalizing Z buffer.

source/blender/compositor/operations/COM_NormalizeOperation.cpp

index 5f7ac6bb9ca7de5df588b68df38b8a0e3d509565..f81b50e6836780443d784969f3103fdd0531a036 100644 (file)
@@ -43,6 +43,12 @@ void NormalizeOperation::executePixel(float output[4], int x, int y, void *data)
        this->m_imageReader->read(output, x, y, NULL);
 
        output[0] = (output[0] - minmult->x) * minmult->y;
+
+       /* clamp infinities */
+       if (output[0] > 1.0f)
+               output[0] = 1.0f;
+       else if (output[0] < 0.0f)
+               output[0] = 0.0f;
 }
 
 void NormalizeOperation::deinitExecution()