[Bf-blender-cvs] [1ca8684] master: Fix T40744: MIP Map is generating strange noise in texture, Blender Internal

Sergey Sharybin noreply at git.blender.org
Mon Aug 11 13:38:13 CEST 2014


Commit: 1ca86849112b6fec869318438a4f3760de49da0e
Author: Sergey Sharybin
Date:   Mon Aug 11 17:37:56 2014 +0600
Branches: master
https://developer.blender.org/rB1ca86849112b6fec869318438a4f3760de49da0e

Fix T40744: MIP Map is generating strange noise in texture, Blender Internal

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

M	source/blender/imbuf/intern/scaling.c

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

diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index e066443..6452e9f 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -33,6 +33,7 @@
 
 
 #include "BLI_utildefines.h"
+#include "BLI_math_base.h"
 #include "BLI_math_color.h"
 #include "BLI_math_interp.h"
 #include "MEM_guardedalloc.h"
@@ -309,18 +310,18 @@ MINLINE void straight_uchar_to_premul_ushort(unsigned short result[4], const uns
 MINLINE void premul_ushort_to_straight_uchar(unsigned char *result, const unsigned short color[4])
 {
 	if (color[3] <= 255) {
-		result[0] = color[0] / 255;
-		result[1] = color[1] / 255;
-		result[2] = color[2] / 255;
-		result[3] = color[3] / 255;
+		result[0] = USHORTTOUCHAR(color[0]);
+		result[1] = USHORTTOUCHAR(color[1]);
+		result[2] = USHORTTOUCHAR(color[2]);
+		result[3] = USHORTTOUCHAR(color[3]);
 	}
 	else {
 		unsigned short alpha = color[3] / 255;
 
-		result[0] = color[0] / alpha;
-		result[1] = color[1] / alpha;
-		result[2] = color[2] / alpha;
-		result[3] = alpha;
+		result[0] = USHORTTOUCHAR(color[0] / alpha * 255);
+		result[1] = USHORTTOUCHAR(color[1] / alpha * 255);
+		result[2] = USHORTTOUCHAR(color[2] / alpha * 255);
+		result[3] = USHORTTOUCHAR(color[3]);
 	}
 }




More information about the Bf-blender-cvs mailing list