[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43809] trunk/blender/source/blender/gpu/ intern: Fix bicubic map sampling to convert the sampled color to monochrome before using it to calculate the derivative .

Antony Riakiotakis kalast at gmail.com
Tue Jan 31 23:12:38 CET 2012


Revision: 43809
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43809
Author:   psy-fi
Date:     2012-01-31 22:12:33 +0000 (Tue, 31 Jan 2012)
Log Message:
-----------
Fix bicubic map sampling to convert the sampled color to monochrome before using it to calculate the derivative. 

Modified Paths:
--------------
    trunk/blender/source/blender/gpu/intern/gpu_shader_material.glsl
    trunk/blender/source/blender/gpu/intern/gpu_shader_material.glsl.c

Modified: trunk/blender/source/blender/gpu/intern/gpu_shader_material.glsl
===================================================================
--- trunk/blender/source/blender/gpu/intern/gpu_shader_material.glsl	2012-01-31 21:56:22 UTC (rev 43808)
+++ trunk/blender/source/blender/gpu/intern/gpu_shader_material.glsl	2012-01-31 22:12:33 UTC (rev 43809)
@@ -1230,6 +1230,11 @@
 void mtex_bump_bicubic( vec3 texco, sampler2D ima, float hScale, 
                      out float dBs, out float dBt ) 
 {
+	float Hl;
+	float Hr;
+	float Hd;
+	float Hu;
+	
 	vec2 TexDx = dFdx(texco.xy);
 	vec2 TexDy = dFdy(texco.xy);
  
@@ -1238,10 +1243,10 @@
 	vec2 STd = texco.xy - 0.5 * TexDy ;
 	vec2 STu = texco.xy + 0.5 * TexDy ;
 	
-	float Hl = texture2D(ima, STl).x;
-	float Hr = texture2D(ima, STr).x;
-	float Hd = texture2D(ima, STd).x;
-	float Hu = texture2D(ima, STu).x;
+	rgbtobw(texture2D(ima, STl), Hl);
+	rgbtobw(texture2D(ima, STr), Hr);
+	rgbtobw(texture2D(ima, STd), Hd);
+	rgbtobw(texture2D(ima, STu), Hu);
 	
 	vec2 dHdxy = vec2(Hr - Hl, Hu - Hd);
 	float fBlend = clamp(1.0-textureQueryLOD(ima, texco.xy).x, 0.0, 1.0);
@@ -1255,8 +1260,6 @@
 		ivec2 iTexLoc = ivec2(floor(fTexLoc));
 		vec2 t = clamp(fTexLoc - iTexLoc, 0.0, 1.0);		// sat just to be pedantic
 
-		ivec2 iTexLocMod = iTexLoc + ivec2(-1, -1);
-
 /*******************************************************************************************
  * This block will replace the one below when one channel textures are properly supported. *
  *******************************************************************************************
@@ -1264,17 +1267,19 @@
 		vec4 vSamplesUR = textureGather(ima, (iTexLoc+ivec2(1,-1) + vec2(0.5,0.5))/vDim );
 		vec4 vSamplesLL = textureGather(ima, (iTexLoc+ivec2(-1,1) + vec2(0.5,0.5))/vDim );
 		vec4 vSamplesLR = textureGather(ima, (iTexLoc+ivec2(1,1) + vec2(0.5,0.5))/vDim );
-		
+
 		mat4 H = mat4(vSamplesUL.w, vSamplesUL.x, vSamplesLL.w, vSamplesLL.x,
 					vSamplesUL.z, vSamplesUL.y, vSamplesLL.z, vSamplesLL.y,
 					vSamplesUR.w, vSamplesUR.x, vSamplesLR.w, vSamplesLR.x,
 					vSamplesUR.z, vSamplesUR.y, vSamplesLR.z, vSamplesLR.y);
 */	
+		ivec2 iTexLocMod = iTexLoc + ivec2(-1, -1);
+
 		mat4 H;
 		
 		for(int i = 0; i < 4; i++){
 			for(int j = 0; j < 4; j++){
-				mtex_rgbtoint(texelFetch(ima, (iTexLocMod + ivec2(i,j)), 0), H[i][j]);
+				rgbtobw(texelFetch(ima, (iTexLocMod + ivec2(i,j)), 0), H[i][j]);
 			}
 		}
 		

Modified: trunk/blender/source/blender/gpu/intern/gpu_shader_material.glsl.c
===================================================================
--- trunk/blender/source/blender/gpu/intern/gpu_shader_material.glsl.c	2012-01-31 21:56:22 UTC (rev 43808)
+++ trunk/blender/source/blender/gpu/intern/gpu_shader_material.glsl.c	2012-01-31 22:12:33 UTC (rev 43809)
@@ -1,1561 +1,1632 @@
 /* DataToC output of file <gpu_shader_material_glsl> */
 
-int datatoc_gpu_shader_material_glsl_size= 49753;
+int datatoc_gpu_shader_material_glsl_size= 52023;
 char datatoc_gpu_shader_material_glsl[]= {
- 10,102,108,111, 97,116, 32,101,120,112, 95, 98,108,101,110,100,101,114, 40,102,108,111, 97,116, 32,
-102, 41, 10,123, 10,  9,114,101,116,117,114,110, 32,112,111,119, 40, 50, 46, 55, 49, 56, 50, 56, 49, 56, 50, 56, 52, 54, 44, 32,
-102, 41, 59, 10,125, 10, 10,118,111,105,100, 32,114,103, 98, 95,116,111, 95,104,115,118, 40,118,101, 99, 52, 32,114,103, 98, 44,
- 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10,  9,102,108,111, 97,116, 32, 99,109, 97,120, 44,
- 32, 99,109,105,110, 44, 32,104, 44, 32,115, 44, 32,118, 44, 32, 99,100,101,108,116, 97, 59, 10,  9,118,101, 99, 51, 32, 99, 59,
- 10, 10,  9, 99,109, 97,120, 32, 61, 32,109, 97,120, 40,114,103, 98, 91, 48, 93, 44, 32,109, 97,120, 40,114,103, 98, 91, 49, 93,
- 44, 32,114,103, 98, 91, 50, 93, 41, 41, 59, 10,  9, 99,109,105,110, 32, 61, 32,109,105,110, 40,114,103, 98, 91, 48, 93, 44, 32,
-109,105,110, 40,114,103, 98, 91, 49, 93, 44, 32,114,103, 98, 91, 50, 93, 41, 41, 59, 10,  9, 99,100,101,108,116, 97, 32, 61, 32,
- 99,109, 97,120, 45, 99,109,105,110, 59, 10, 10,  9,118, 32, 61, 32, 99,109, 97,120, 59, 10,  9,105,102, 32, 40, 99,109, 97,120,
- 33, 61, 48, 46, 48, 41, 10,  9,  9,115, 32, 61, 32, 99,100,101,108,116, 97, 47, 99,109, 97,120, 59, 10,  9,101,108,115,101, 32,
-123, 10,  9,  9,115, 32, 61, 32, 48, 46, 48, 59, 10,  9,  9,104, 32, 61, 32, 48, 46, 48, 59, 10,  9,125, 10, 10,  9,105,102, 32,
- 40,115, 32, 61, 61, 32, 48, 46, 48, 41, 32,123, 10,  9,  9,104, 32, 61, 32, 48, 46, 48, 59, 10,  9,125, 10,  9,101,108,115,101,
- 32,123, 10,  9,  9, 99, 32, 61, 32, 40,118,101, 99, 51, 40, 99,109, 97,120, 44, 32, 99,109, 97,120, 44, 32, 99,109, 97,120, 41,
- 32, 45, 32,114,103, 98, 46,120,121,122, 41, 47, 99,100,101,108,116, 97, 59, 10, 10,  9,  9,105,102, 32, 40,114,103, 98, 46,120,
- 61, 61, 99,109, 97,120, 41, 32,104, 32, 61, 32, 99, 91, 50, 93, 32, 45, 32, 99, 91, 49, 93, 59, 10,  9,  9,101,108,115,101, 32,
+ 13, 10,102,108,111, 97,116, 32,101,120,112, 95, 98,108,101,110,100,101,114, 40,102,108,111,
+ 97,116, 32,102, 41, 13, 10,123, 13, 10,  9,114,101,116,117,114,110, 32,112,111,119, 40, 50, 46, 55, 49, 56, 50, 56, 49, 56, 50,
+ 56, 52, 54, 44, 32,102, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,114,103, 98, 95,116,111, 95,104,115,118, 40,118,
+101, 99, 52, 32,114,103, 98, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10,  9,102,
+108,111, 97,116, 32, 99,109, 97,120, 44, 32, 99,109,105,110, 44, 32,104, 44, 32,115, 44, 32,118, 44, 32, 99,100,101,108,116, 97,
+ 59, 13, 10,  9,118,101, 99, 51, 32, 99, 59, 13, 10, 13, 10,  9, 99,109, 97,120, 32, 61, 32,109, 97,120, 40,114,103, 98, 91, 48,
+ 93, 44, 32,109, 97,120, 40,114,103, 98, 91, 49, 93, 44, 32,114,103, 98, 91, 50, 93, 41, 41, 59, 13, 10,  9, 99,109,105,110, 32,
+ 61, 32,109,105,110, 40,114,103, 98, 91, 48, 93, 44, 32,109,105,110, 40,114,103, 98, 91, 49, 93, 44, 32,114,103, 98, 91, 50, 93,
+ 41, 41, 59, 13, 10,  9, 99,100,101,108,116, 97, 32, 61, 32, 99,109, 97,120, 45, 99,109,105,110, 59, 13, 10, 13, 10,  9,118, 32,
+ 61, 32, 99,109, 97,120, 59, 13, 10,  9,105,102, 32, 40, 99,109, 97,120, 33, 61, 48, 46, 48, 41, 13, 10,  9,  9,115, 32, 61, 32,
+ 99,100,101,108,116, 97, 47, 99,109, 97,120, 59, 13, 10,  9,101,108,115,101, 32,123, 13, 10,  9,  9,115, 32, 61, 32, 48, 46, 48,
+ 59, 13, 10,  9,  9,104, 32, 61, 32, 48, 46, 48, 59, 13, 10,  9,125, 13, 10, 13, 10,  9,105,102, 32, 40,115, 32, 61, 61, 32, 48,
+ 46, 48, 41, 32,123, 13, 10,  9,  9,104, 32, 61, 32, 48, 46, 48, 59, 13, 10,  9,125, 13, 10,  9,101,108,115,101, 32,123, 13, 10,
+  9,  9, 99, 32, 61, 32, 40,118,101, 99, 51, 40, 99,109, 97,120, 44, 32, 99,109, 97,120, 44, 32, 99,109, 97,120, 41, 32, 45, 32,
+114,103, 98, 46,120,121,122, 41, 47, 99,100,101,108,116, 97, 59, 13, 10, 13, 10,  9,  9,105,102, 32, 40,114,103, 98, 46,120, 61,
+ 61, 99,109, 97,120, 41, 32,104, 32, 61, 32, 99, 91, 50, 93, 32, 45, 32, 99, 91, 49, 93, 59, 13, 10,  9,  9,101,108,115,101, 32,
 105,102, 32, 40,114,103, 98, 46,121, 61, 61, 99,109, 97,120, 41, 32,104, 32, 61, 32, 50, 46, 48, 32, 43, 32, 99, 91, 48, 93, 32,
- 45, 32, 32, 99, 91, 50, 93, 59, 10,  9,  9,101,108,115,101, 32,104, 32, 61, 32, 52, 46, 48, 32, 43, 32, 99, 91, 49, 93, 32, 45,
- 32, 99, 91, 48, 93, 59, 10, 10,  9,  9,104, 32, 47, 61, 32, 54, 46, 48, 59, 10, 10,  9,  9,105,102, 32, 40,104, 60, 48, 46, 48,
- 41, 10,  9,  9,  9,104, 32, 43, 61, 32, 49, 46, 48, 59, 10,  9,125, 10, 10,  9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99,
- 52, 40,104, 44, 32,115, 44, 32,118, 44, 32,114,103, 98, 46,119, 41, 59, 10,125, 10, 10,118,111,105,100, 32,104,115,118, 95,116,
-111, 95,114,103, 98, 40,118,101, 99, 52, 32,104,115,118, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41,
- 10,123, 10,  9,102,108,111, 97,116, 32,105, 44, 32,102, 44, 32,112, 44, 32,113, 44, 32,116, 44, 32,104, 44, 32,115, 44, 32,118,
- 59, 10,  9,118,101, 99, 51, 32,114,103, 98, 59, 10, 10,  9,104, 32, 61, 32,104,115,118, 91, 48, 93, 59, 10,  9,115, 32, 61, 32,
-104,115,118, 91, 49, 93, 59, 10,  9,118, 32, 61, 32,104,115,118, 91, 50, 93, 59, 10, 10,  9,105,102, 40,115, 61, 61, 48, 46, 48,
- 41, 32,123, 10,  9,  9,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,118, 44, 32,118, 44, 32,118, 41, 59, 10,  9,125, 10,  9,101,
-108,115,101, 32,123, 10,  9,  9,105,102, 40,104, 61, 61, 49, 46, 48, 41, 10,  9,  9,  9,104, 32, 61, 32, 48, 46, 48, 59, 10,  9,
-  9, 10,  9,  9,104, 32, 42, 61, 32, 54, 46, 48, 59, 10,  9,  9,105, 32, 61, 32,102,108,111,111,114, 40,104, 41, 59, 10,  9,  9,
-102, 32, 61, 32,104, 32, 45, 32,105, 59, 10,  9,  9,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,102, 44, 32,102, 44, 32,102, 41,
- 59, 10,  9,  9,112, 32, 61, 32,118, 42, 40, 49, 46, 48, 45,115, 41, 59, 10,  9,  9,113, 32, 61, 32,118, 42, 40, 49, 46, 48, 45,
- 40,115, 42,102, 41, 41, 59, 10,  9,  9,116, 32, 61, 32,118, 42, 40, 49, 46, 48, 45, 40,115, 42, 40, 49, 46, 48, 45,102, 41, 41,
- 41, 59, 10,  9,  9, 10,  9,  9,105,102, 32, 40,105, 32, 61, 61, 32, 48, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51,
- 40,118, 44, 32,116, 44, 32,112, 41, 59, 10,  9,  9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 49, 46, 48, 41, 32,
-114,103, 98, 32, 61, 32,118,101, 99, 51, 40,113, 44, 32,118, 44, 32,112, 41, 59, 10,  9,  9,101,108,115,101, 32,105,102, 32, 40,
-105, 32, 61, 61, 32, 50, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,112, 44, 32,118, 44, 32,116, 41, 59, 10,  9,
-  9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 51, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,112,
- 44, 32,113, 44, 32,118, 41, 59, 10,  9,  9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 52, 46, 48, 41, 32,114,103,
- 98, 32, 61, 32,118,101, 99, 51, 40,116, 44, 32,112, 44, 32,118, 41, 59, 10,  9,  9,101,108,115,101, 32,114,103, 98, 32, 61, 32,
-118,101, 99, 51, 40,118, 44, 32,112, 44, 32,113, 41, 59, 10,  9,125, 10, 10,  9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99,
- 52, 40,114,103, 98, 44, 32,104,115,118, 46,119, 41, 59, 10,125, 10, 10,102,108,111, 97,116, 32,115,114,103, 98, 95,116,111, 95,
-108,105,110,101, 97,114,114,103, 98, 40,102,108,111, 97,116, 32, 99, 41, 10,123, 10,  9,105,102, 40, 99, 32, 60, 32, 48, 46, 48,
- 52, 48, 52, 53, 41, 10,  9,  9,114,101,116,117,114,110, 32, 40, 99, 32, 60, 32, 48, 46, 48, 41, 63, 32, 48, 46, 48, 58, 32, 99,

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-blender-cvs mailing list