[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42286] branches/ge_harmony/source/blender /gpu/intern: Lamp textures now use their actual color values instead of intensity.

Mitchell Stokes mogurijin at gmail.com
Wed Nov 30 07:24:43 CET 2011


Revision: 42286
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42286
Author:   moguri
Date:     2011-11-30 06:24:39 +0000 (Wed, 30 Nov 2011)
Log Message:
-----------
Lamp textures now use their actual color values instead of intensity. Also, the various blend modes are now supported (use Multiply to get similar behavior to the previous cookie code).

Modified Paths:
--------------
    branches/ge_harmony/source/blender/gpu/intern/gpu_material.c
    branches/ge_harmony/source/blender/gpu/intern/gpu_shader_material.glsl
    branches/ge_harmony/source/blender/gpu/intern/gpu_shader_material.glsl.c

Modified: branches/ge_harmony/source/blender/gpu/intern/gpu_material.c
===================================================================
--- branches/ge_harmony/source/blender/gpu/intern/gpu_material.c	2011-11-30 06:15:35 UTC (rev 42285)
+++ branches/ge_harmony/source/blender/gpu/intern/gpu_material.c	2011-11-30 06:24:39 UTC (rev 42286)
@@ -137,6 +137,9 @@
 	ListBase materials;
 };
 
+/* Forward declaration so shade_light_cookies() can use this, while still keeping the code somewhat organized */
+static void texture_rgb_blend(GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *out, GPUNodeLink *fact, GPUNodeLink *facg, int blendtype, GPUNodeLink **in);
+
 /* Functions */
 
 static GPUMaterial *GPU_material_construct_begin(Material *ma)
@@ -613,6 +616,28 @@
 	BLI_addtail(list, link);
 }
 
+static void shade_light_cookies(GPUMaterial *mat, GPULamp *lamp, GPUNodeLink **rgb)
+{
+	int i;
+	float one = 1.f;
+	GPUNodeLink *cookie_rgb;
+	MTex *mtex = NULL;
+
+	for (i=0; i<MAX_MTEX; ++i) {
+		mtex = lamp->la->mtex[i];
+
+		if (mtex && mtex->tex->type & TEX_IMAGE	&& mtex->tex->ima) {
+			GPUTexture* cookie = GPU_texture_from_blender(mtex->tex->ima, &mtex->tex->iuser, 1.0, 0);
+			GPU_link(mat, "shade_light_cookie",
+				GPU_builtin(GPU_VIEW_POSITION),
+				GPU_dynamic_texture(cookie,  GPU_DYNAMIC_SAMPLER_2DIMAGE, lamp->ob),
+				GPU_dynamic_uniform((float*)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
+				&cookie_rgb);
+			texture_rgb_blend(mat, cookie_rgb, *rgb, GPU_uniform(&one), GPU_uniform(&mtex->colfac), mtex->blendtype, rgb); 
+		}
+	}
+}
+
 static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *lamp)
 {
 	Material *ma= shi->mat;
@@ -620,7 +645,6 @@
 	GPUNodeLink *lv, *dist, *visifac, *is, *inp, *i, *vn, *view;
 	GPUNodeLink *outcol, *specfac, *t, *shadcol, *shadfac= NULL;
 	float one = 1.0f;
-	int j;
 
 	if((lamp->mode & LA_ONLYSHADOW) && !(ma->mode & MA_SHADOW))
 		return;
@@ -687,27 +711,16 @@
 				GPU_dynamic_texture(lamp->tex, GPU_DYNAMIC_SAMPLER_2DSHADOW, lamp->ob),
 				GPU_dynamic_uniform((float*)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
 				GPU_uniform(&lamp->bias), inp, &shadfac);
-
-			for (j=0; j<MAX_MTEX; ++j) {
-				if (lamp->la->mtex[j]
-					&& lamp->la->mtex[j]->tex->type & TEX_IMAGE
-					&& lamp->la->mtex[j]->tex->ima) {
-					GPUTexture* cookie = GPU_texture_from_blender(lamp->la->mtex[j]->tex->ima, &lamp->la->mtex[j]->tex->iuser, 1.0, 0);
-					GPU_link(mat, "test_shadowbuf_cookie",
-						GPU_builtin(GPU_VIEW_POSITION),
-						GPU_dynamic_texture(cookie,  GPU_DYNAMIC_SAMPLER_2DSHADOW, lamp->ob),
-						GPU_dynamic_uniform((float*)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
-						shadfac, &shadfac);
-				}
-			}
 			
 			if(lamp->mode & LA_ONLYSHADOW) {
 				GPU_link(mat, "shade_only_shadow", i, shadfac,
 					GPU_dynamic_uniform(&lamp->dynenergy, GPU_DYNAMIC_LAMP_DYNENERGY, lamp->ob), &shadfac);
 				
-				if(!(lamp->mode & LA_NO_DIFF))
+				if(!(lamp->mode & LA_NO_DIFF)) {
 					GPU_link(mat, "mix_mult", shadfac, shr->diff,
 						GPU_uniform(lamp->shadow_color), &shr->diff);
+					shade_light_cookies(mat, lamp, &shr->diff);
+				}
 
 				if(!(lamp->mode & LA_NO_SPEC))
 					GPU_link(mat, "shade_only_shadow_specular", shadfac, shi->specrgb,
@@ -733,6 +746,7 @@
 			GPU_link(mat, "shade_mul_value", i, GPU_dynamic_uniform(lamp->dyncol, GPU_DYNAMIC_LAMP_DYNCOL, lamp->ob), &rgb);
 			GPU_link(mat, "mtex_value_invert", shadfac, &shadfac);
 			GPU_link(mat, "mix_mult",  shadfac, rgb, GPU_uniform(lamp->shadow_color), &rgb);
+			shade_light_cookies(mat, lamp, &rgb);
             add_to_diffuse(mat, ma, shi, is, rgb, &shr->diff);
 		}
 	}

Modified: branches/ge_harmony/source/blender/gpu/intern/gpu_shader_material.glsl
===================================================================
--- branches/ge_harmony/source/blender/gpu/intern/gpu_shader_material.glsl	2011-11-30 06:15:35 UTC (rev 42285)
+++ branches/ge_harmony/source/blender/gpu/intern/gpu_shader_material.glsl	2011-11-30 06:24:39 UTC (rev 42286)
@@ -1789,16 +1789,12 @@
 	}
 }
 
-void test_shadowbuf_cookie(vec3 rco, sampler2DShadow cookie, mat4 shadowpersmat, float inp, out float result)
+void shade_light_cookie(vec3 rco, sampler2D cookie, mat4 shadowpersmat, out vec4 result)
 {
-	if(inp <= 0.0) {
-		result = 0.0;
-	}
-	else {
-		vec4 co = shadowpersmat*vec4(rco, 1.0);
 
-		result = inp*shadow2DProj(cookie, co).x;
-	}
+	vec4 co = shadowpersmat*vec4(rco, 1.0);
+
+	result = texture2DProj(cookie, co);
 }
 
 void shade_exposure_correct(vec3 col, float linfac, float logfac, out vec3 outcol)

Modified: branches/ge_harmony/source/blender/gpu/intern/gpu_shader_material.glsl.c
===================================================================
--- branches/ge_harmony/source/blender/gpu/intern/gpu_shader_material.glsl.c	2011-11-30 06:15:35 UTC (rev 42285)
+++ branches/ge_harmony/source/blender/gpu/intern/gpu_shader_material.glsl.c	2011-11-30 06:24:39 UTC (rev 42286)
@@ -1,1303 +1,1301 @@
 /* DataToC output of file <gpu_shader_material_glsl> */
 
-int datatoc_gpu_shader_material_glsl_size= 49273;
+int datatoc_gpu_shader_material_glsl_size= 49194;
 char datatoc_gpu_shader_material_glsl[]= {
- 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, 13, 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, 13, 10, 13, 10,  9,  9,104, 32, 47, 61, 32, 54, 46, 48, 59, 13, 10, 13, 10,  9,  9,105,102, 32, 40,104, 60,
- 48, 46, 48, 41, 13, 10,  9,  9,  9,104, 32, 43, 61, 32, 49, 46, 48, 59, 13, 10,  9,125, 13, 10, 13, 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, 13, 10,125, 13, 10, 13, 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, 13, 10,123, 13, 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, 13, 10,  9,118,101, 99, 51, 32,114,103, 98, 59, 13, 10, 13, 10,  9,104, 32,
- 61, 32,104,115,118, 91, 48, 93, 59, 13, 10,  9,115, 32, 61, 32,104,115,118, 91, 49, 93, 59, 13, 10,  9,118, 32, 61, 32,104,115,
-118, 91, 50, 93, 59, 13, 10, 13, 10,  9,105,102, 40,115, 61, 61, 48, 46, 48, 41, 32,123, 13, 10,  9,  9,114,103, 98, 32, 61, 32,
-118,101, 99, 51, 40,118, 44, 32,118, 44, 32,118, 41, 59, 13, 10,  9,125, 13, 10,  9,101,108,115,101, 32,123, 13, 10,  9,  9,105,
-102, 40,104, 61, 61, 49, 46, 48, 41, 13, 10,  9,  9,  9,104, 32, 61, 32, 48, 46, 48, 59, 13, 10,  9,  9, 13, 10,  9,  9,104, 32,
- 42, 61, 32, 54, 46, 48, 59, 13, 10,  9,  9,105, 32, 61, 32,102,108,111,111,114, 40,104, 41, 59, 13, 10,  9,  9,102, 32, 61, 32,
-104, 32, 45, 32,105, 59, 13, 10,  9,  9,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,102, 44, 32,102, 44, 32,102, 41, 59, 13, 10,
-  9,  9,112, 32, 61, 32,118, 42, 40, 49, 46, 48, 45,115, 41, 59, 13, 10,  9,  9,113, 32, 61, 32,118, 42, 40, 49, 46, 48, 45, 40,
-115, 42,102, 41, 41, 59, 13, 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, 13, 10,  9,  9, 13, 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, 13, 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, 13, 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, 13, 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, 13, 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, 13, 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, 13, 10,  9,125, 13, 10, 13, 10,  9,111,117,

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list