[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11574] branches/soc-2007-maike:
Brecht Van Lommel
brechtvanlommel at pandora.be
Mon Aug 13 20:04:38 CEST 2007
Revision: 11574
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11574
Author: blendix
Date: 2007-08-13 20:04:38 +0200 (Mon, 13 Aug 2007)
Log Message:
-----------
GLSL Branch
===========
- Fix two memory leaks in code generation.
- Compatibility fix in spot visibility, orennayer.
Modified Paths:
--------------
branches/soc-2007-maike/release/glsl/orennayar.gsl
branches/soc-2007-maike/release/glsl/orennayar_area.gsl
branches/soc-2007-maike/release/glsl/spot_visibility.gsl
branches/soc-2007-maike/source/blender/src/glsl_material_node.c
branches/soc-2007-maike/source/blender/src/glsl_node_util.c
Modified: branches/soc-2007-maike/release/glsl/orennayar.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/orennayar.gsl 2007-08-13 14:52:17 UTC (rev 11573)
+++ branches/soc-2007-maike/release/glsl/orennayar.gsl 2007-08-13 18:04:38 UTC (rev 11574)
@@ -6,8 +6,8 @@
float nv = max(dot(vnormal, view), 0.0);
float nl = max(dot(vnormal, lightVec), 0.0);
float vh = max(dot(view, h), 0.0);
- float lit_A = acos(clamp(nl, -1.0, 1.0)) * (1 - floor(clamp(nl, 0.1, 1.0) + 0.00001));
- float view_A = acos(clamp(nv, -1.0, 1.0)) * (1 - floor(clamp(nv, 0.1, 1.0) + 0.00001));
+ float lit_A = acos(clamp(nl, -1.0, 1.0)) * (1.0 - floor(clamp(nl, 0.1, 1.0) + 0.00001));
+ float view_A = acos(clamp(nv, -1.0, 1.0)) * (1.0 - floor(clamp(nv, 0.1, 1.0) + 0.00001));
vec3 lit_B = normalize(lightVec - (nl * vnormal));
vec3 view_B = normalize(view - (nv * vnormal));
float t = max(dot(lit_B, view_B), 0.0);
Modified: branches/soc-2007-maike/release/glsl/orennayar_area.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/orennayar_area.gsl 2007-08-13 14:52:17 UTC (rev 11573)
+++ branches/soc-2007-maike/release/glsl/orennayar_area.gsl 2007-08-13 18:04:38 UTC (rev 11574)
@@ -21,10 +21,10 @@
rad[2] = dot(vect3, vect4);
rad[3] = dot(vect4, vect1);
- rad[0] = acos(clamp(rad[0], -1.0, 1.0)) * (1 - floor(clamp(rad[0], 0.1, 1.0) + 0.00001));
- rad[1] = acos(clamp(rad[1], -1.0, 1.0)) * (1 - floor(clamp(rad[1], 0.1, 1.0) + 0.00001));
- rad[2] = acos(clamp(rad[2], -1.0, 1.0)) * (1 - floor(clamp(rad[2], 0.1, 1.0) + 0.00001));
- rad[3] = acos(clamp(rad[3], -1.0, 1.0)) * (1 - floor(clamp(rad[3], 0.1, 1.0) + 0.00001));
+ rad[0] = acos(clamp(rad[0], -1.0, 1.0)) * (1.0 - floor(clamp(rad[0], 0.1, 1.0) + 0.00001));
+ rad[1] = acos(clamp(rad[1], -1.0, 1.0)) * (1.0 - floor(clamp(rad[1], 0.1, 1.0) + 0.00001));
+ rad[2] = acos(clamp(rad[2], -1.0, 1.0)) * (1.0 - floor(clamp(rad[2], 0.1, 1.0) + 0.00001));
+ rad[3] = acos(clamp(rad[3], -1.0, 1.0)) * (1.0 - floor(clamp(rad[3], 0.1, 1.0) + 0.00001));
fac = rad[0] * dot(vnormal, cross1);
fac += rad[1] * dot(vnormal, cross2);
@@ -45,8 +45,8 @@
float nv = max(dot(vnormal, view), 0.0);
float nl = orennayar_area_energy(l, vnormal);
float vh = max(dot(view, h), 0.0);
- float lit_A = acos(clamp(nl, -1.0, 1.0)) * (1 - floor(clamp(nl, 0.1, 1.0) + 0.00001));
- float view_A = acos(clamp(nv, -1.0, 1.0)) * (1 - floor(clamp(nv, 0.1, 1.0) + 0.00001));
+ float lit_A = acos(clamp(nl, -1.0, 1.0)) * (1.0 - floor(clamp(nl, 0.1, 1.0) + 0.00001));
+ float view_A = acos(clamp(nv, -1.0, 1.0)) * (1.0 - floor(clamp(nv, 0.1, 1.0) + 0.00001));
vec3 lit_B = normalize(lightVec - (nl * vnormal));
vec3 view_B = normalize(view - (nv * vnormal));
float t = max(dot(lit_B, view_B), 0.0);
Modified: branches/soc-2007-maike/release/glsl/spot_visibility.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/spot_visibility.gsl 2007-08-13 14:52:17 UTC (rev 11573)
+++ branches/soc-2007-maike/release/glsl/spot_visibility.gsl 2007-08-13 18:04:38 UTC (rev 11574)
@@ -19,7 +19,7 @@
visifac *= max(m / l.dist, l.sphere);
if(visifac > 0.0){
- if(l.square){
+ if(l.square != 0.0){
if(dot(lv, vec) > 0.0){
matr[0] = vec3(l.mat[0][0], l.mat[0][1], l.mat[0][2]);
matr[1] = vec3(l.mat[1][0], l.mat[1][1], l.mat[1][2]);
Modified: branches/soc-2007-maike/source/blender/src/glsl_material_node.c
===================================================================
--- branches/soc-2007-maike/source/blender/src/glsl_material_node.c 2007-08-13 14:52:17 UTC (rev 11573)
+++ branches/soc-2007-maike/source/blender/src/glsl_material_node.c 2007-08-13 18:04:38 UTC (rev 11574)
@@ -209,11 +209,9 @@
if(!diffuse)
return NULL;
- code = glsl_string(2,
- GFREE, code,
- GFREE, diffuse);
+ if(strcmp(diffuse, "") != 0)
+ code = glsl_string(2, GFREE, code, GFREE, diffuse);
-
specular = glsl_specular_func(spec);
if(!specular){
if(code){
@@ -221,11 +219,10 @@
return NULL;
}
}
-
- code = glsl_string(2,
- GFREE, code,
- GFREE, specular);
+ if(strcmp(specular, "") != 0)
+ code = glsl_string(2, GFREE, code, GFREE, specular);
+
visibility = glsl_visibility_func(vis);
if(visibility && strcmp(visibility, "") != 0)
code = glsl_string(2,
Modified: branches/soc-2007-maike/source/blender/src/glsl_node_util.c
===================================================================
--- branches/soc-2007-maike/source/blender/src/glsl_node_util.c 2007-08-13 14:52:17 UTC (rev 11573)
+++ branches/soc-2007-maike/source/blender/src/glsl_node_util.c 2007-08-13 18:04:38 UTC (rev 11574)
@@ -156,6 +156,7 @@
printf("\n Code:\n%s\n", code);
shader = glsl_create_GLshader(code, GL_FRAGMENT_SHADER, 1);
+ MEM_freeN(program_node);
return shader;
}
@@ -234,10 +235,11 @@
MEM_freeN(program_node);
return NULL;
}
- else if(cb_blend_funcs && strcmp(cb_blend_funcs, "") != 0)
+ else if(strcmp(cb_blend_funcs, "") != 0) {
program_node->node_code = glsl_string(2,
GFREE, cb_blend_funcs,
GFREE, program_node->node_code);
+ }
light_funcs = glsl_write_light_funcs(diffuse, specular, visibility);
@@ -246,15 +248,15 @@
MEM_freeN(program_node->node_code);
MEM_freeN(program_node);
- if(!strcmp(cb_blend_funcs, ""))
- MEM_freeN(cb_blend_funcs);
return NULL;
}
-
- else if(light_funcs && strcmp(light_funcs, "") != 0)
+ else if(strcmp(light_funcs, "") != 0) {
program_node->node_code = glsl_string(2,
GFREE, light_funcs,
GFREE, program_node->node_code);
+ }
+ else
+ MEM_freeN(light_funcs);
program_node->node_code = glsl_string(2,
GFREE, program_node->node_code,
More information about the Bf-blender-cvs
mailing list