[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11334] branches/soc-2007-maike: Added events for ambient and emit factors and added emit calculation

Miguel Torres Lima torreslima at gmail.com
Sun Jul 22 18:32:43 CEST 2007


Revision: 11334
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11334
Author:   maike
Date:     2007-07-22 18:32:42 +0200 (Sun, 22 Jul 2007)

Log Message:
-----------
Added events for ambient and emit factors and added emit calculation

Modified Paths:
--------------
    branches/soc-2007-maike/release/glsl/light_calc.gsl
    branches/soc-2007-maike/source/blender/src/buttons_shading.c
    branches/soc-2007-maike/source/blender/src/glsl_drawobject.c
    branches/soc-2007-maike/source/blender/src/glsl_uniforms.c

Modified: branches/soc-2007-maike/release/glsl/light_calc.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/light_calc.gsl	2007-07-22 14:09:01 UTC (rev 11333)
+++ branches/soc-2007-maike/release/glsl/light_calc.gsl	2007-07-22 16:32:42 UTC (rev 11334)
@@ -19,14 +19,14 @@
 float diff_fac = dot((eye - pos), normal);
 #endif
 #endif
-vec3 diff_col = rslt1 * diff1 * diff_color * vec3(lights[LIGHT_ID].color + vert_color);
+vec3 diff_col = (rslt1 + emit) * diff1 * diff_color * vec3(lights[LIGHT_ID].color + vert_color);
 vec4 diff_cb = texture1D(DIFF_CB_TEX, diff_fac);
 diff_rslt += DIFF_CB_BLEND_FUNC(diff_col, diff_cb.rgb, DIFF_CB_FAC) * lights[LIGHT_ID].layer * lights[LIGHT_ID].energy * vis;
 #else
 #ifdef HEMI
-diff_rslt+= DIFF_SHADER_ID(lights[LIGHT_ID], normal) * diff1 * diff_color * vec3(lights[LIGHT_ID].color + vert_color) * lights[LIGHT_ID].layer * lights[LIGHT_ID].energy * vis;
+diff_rslt+= (DIFF_SHADER_ID(lights[LIGHT_ID], normal) + emit) * diff1 * diff_color * vec3(lights[LIGHT_ID].color + vert_color) * lights[LIGHT_ID].layer * lights[LIGHT_ID].energy * vis;
 #else
-diff_rslt+= DIFF_SHADER_ID(lights[LIGHT_ID], normal, diff2, diff3) * diff1 * diff_color * vec3(lights[LIGHT_ID].color + vert_color) * lights[LIGHT_ID].layer * lights[LIGHT_ID].energy * vis;	
+diff_rslt+= (DIFF_SHADER_ID(lights[LIGHT_ID], normal, diff2, diff3) + emit) * diff1 * diff_color * vec3(lights[LIGHT_ID].color + vert_color) * lights[LIGHT_ID].layer * lights[LIGHT_ID].energy * vis;	
 #endif
 #endif
 #endif

Modified: branches/soc-2007-maike/source/blender/src/buttons_shading.c
===================================================================
--- branches/soc-2007-maike/source/blender/src/buttons_shading.c	2007-07-22 14:09:01 UTC (rev 11333)
+++ branches/soc-2007-maike/source/blender/src/buttons_shading.c	2007-07-22 16:32:42 UTC (rev 11334)
@@ -3646,8 +3646,8 @@
 		uiBlockBeginAlign(block);
 		uiDefButF(block, NUMSLI, B_MATPRV, "Tralu ",	9,30,150,19, &(ma->translucency), 0.0, 1.0, 100, 2, "Translucency, amount of diffuse shading of the back side");
 		uiDefButF(block, NUMSLI, B_MATPRV, "SBias ",	159,30,151,19, &(ma->sbias), 0.0, 0.25, 10, 2, "Shadow bias, to prevent terminator problems on shadow boundary");
-		uiDefButF(block, NUMSLI, B_MATPRV, "Amb ",		9,10,150,19, &(ma->amb), 0.0, 1.0, 0, 0, "Sets the amount of global ambient color the material receives");
-		uiDefButF(block, NUMSLI, B_MATPRV, "Emit ",		159,10,151,19, &(ma->emit), 0.0, 1.0, 0, 0, "Sets the amount of light the material emits");
+		uiDefButF(block, NUMSLI, B_MAT_UNIFS, "Amb ",		9,10,150,19, &(ma->amb), 0.0, 1.0, 0, 0, "Sets the amount of global ambient color the material receives");
+		uiDefButF(block, NUMSLI, B_MAT_UNIFS, "Emit ",		159,10,151,19, &(ma->emit), 0.0, 1.0, 0, 0, "Sets the amount of light the material emits");
 		uiBlockEndAlign(block);
 
 		uiBlockSetCol(block, TH_BUT_SETTING1);

Modified: branches/soc-2007-maike/source/blender/src/glsl_drawobject.c
===================================================================
--- branches/soc-2007-maike/source/blender/src/glsl_drawobject.c	2007-07-22 14:09:01 UTC (rev 11333)
+++ branches/soc-2007-maike/source/blender/src/glsl_drawobject.c	2007-07-22 16:32:42 UTC (rev 11334)
@@ -371,11 +371,11 @@
       else{
 	program = glsl_get_material_program(mat, GLSL_TEXTURED);
       }
+      glsl_update_colorband_uniforms(program->program, mat, 0);
       glUseProgram(program->program);
       glsl_light_uniforms(program->program, ob);
       oldmat = mat;
     }
-    
 
 
     glBegin(face->v4?GL_QUADS:GL_TRIANGLES);

Modified: branches/soc-2007-maike/source/blender/src/glsl_uniforms.c
===================================================================
--- branches/soc-2007-maike/source/blender/src/glsl_uniforms.c	2007-07-22 14:09:01 UTC (rev 11333)
+++ branches/soc-2007-maike/source/blender/src/glsl_uniforms.c	2007-07-22 16:32:42 UTC (rev 11334)
@@ -366,7 +366,7 @@
     GLSL_ColorBand colorband = material->diff_ramp;
 
     diff_fac = glsl_string(5, 0, "u_mat_", GINT, index, 0, "_ramp_", GINT, 0, 0, "_fac");
-    printf("\nlocation: %d N%sN %d\n", glsl_uniform_location(program, diff_fac), diff_fac, strlen(diff_fac));
+    printf("\nlocation: %d N%sN %d\n", glsl_uniform_location(program, diff_fac), diff_fac, strlen(diff_fac));   
     glUniform1f(glsl_uniform_location(program, diff_fac), mat->rampfac_col);
 
     printf("\ngl error colorband2: %d - %f\n", glGetError(), mat->rampfac_col);
@@ -385,8 +385,12 @@
   if(mat->mode & MA_RAMP_SPEC){
     GLSL_ColorBand colorband = material->spec_ramp;
 
-    spec_fac = glsl_string(3, 0, "u_mat_", GINT, index, 0, "_specramp_fac");
-    glUniform1f(glsl_uniform_location(program, spec_fac), mat->rampfac_spec);
+    spec_fac = glsl_string(5, 0, "u_mat_", GINT, index, 0, "_ramp_", GINT, 1, 0, "_fac");    
+    printf("\nlocation: %d N%sN %d\n", glsl_uniform_location(program, spec_fac), spec_fac, strlen(spec_fac));
+    glUniform1f(glsl_uniform_location(program, spec_fac), mat->rampfac_spec);   
+
+    printf("\ngl error colorband2: %d - %f\n", glGetError(), mat->rampfac_col);
+ 
     spec_tex = glsl_string(5, 0, "u_mat_", GINT, index, 0, "_ramp_", GINT, 1, 0, "_tex");
     glActiveTexture(GL_TEXTURE0 + colorband->texid);
     glBindTexture(GL_TEXTURE_1D, colorband->texid);
@@ -397,5 +401,5 @@
     MEM_freeN(spec_fac);
     MEM_freeN(spec_tex);
     printf("\nGLSL Specular Colorband Uniform sent\n");
-  } printf("\ngl error colorband: %d\n", glGetError());
+  }
 }





More information about the Bf-blender-cvs mailing list