[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11394] branches/soc-2007-maike/source/ blender: Separated colorband factor uniform from colorband texture uniform.
Miguel Torres Lima
torreslima at gmail.com
Fri Jul 27 19:45:30 CEST 2007
Revision: 11394
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11394
Author: maike
Date: 2007-07-27 19:45:30 +0200 (Fri, 27 Jul 2007)
Log Message:
-----------
Separated colorband factor uniform from colorband texture uniform.
Modified Paths:
--------------
branches/soc-2007-maike/source/blender/include/BIF_glsl_uniforms.h
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/source/blender/include/BIF_glsl_uniforms.h
===================================================================
--- branches/soc-2007-maike/source/blender/include/BIF_glsl_uniforms.h 2007-07-27 17:13:41 UTC (rev 11393)
+++ branches/soc-2007-maike/source/blender/include/BIF_glsl_uniforms.h 2007-07-27 17:45:30 UTC (rev 11394)
@@ -46,10 +46,13 @@
#ifdef __APPLE__
void glsl_update_colorband_uniforms(unsigned long program, struct Material *mat, int index);
+void glsl_update_colorband_tex_uniforms(unsigned long program, struct Material *mat, int index);
#else
void glsl_update_colorband_uniforms(unsigned int program, struct Material *mat, int index);
+void glsl_update_colorband_tex_uniforms(unsigned int program, struct Material *mat, int index);
#endif
+
void glsl_update_all_light_uniforms(struct GLSL_MaterialTree_ *tree);
void glsl_update_light_uniforms(struct GLSL_Light_ *light, struct Lamp *lamp, struct GLSL_MaterialTree_ *vtree);
Modified: branches/soc-2007-maike/source/blender/src/glsl_drawobject.c
===================================================================
--- branches/soc-2007-maike/source/blender/src/glsl_drawobject.c 2007-07-27 17:13:41 UTC (rev 11393)
+++ branches/soc-2007-maike/source/blender/src/glsl_drawobject.c 2007-07-27 17:45:30 UTC (rev 11394)
@@ -34,6 +34,7 @@
#include "BIF_gl.h"
#include "BIF_glsl_drawobject.h"
#include "BIF_glsl_colorband.h"
+#include "BIF_glsl_uniforms.h"
#include "BSE_view.h"
@@ -377,7 +378,7 @@
oldmat = mat;
if(mat){
- glsl_update_colorband_uniforms(program->program, mat, 0);
+ glsl_update_colorband_tex_uniforms(program->program, mat, 0);
}
}
Modified: branches/soc-2007-maike/source/blender/src/glsl_uniforms.c
===================================================================
--- branches/soc-2007-maike/source/blender/src/glsl_uniforms.c 2007-07-27 17:13:41 UTC (rev 11393)
+++ branches/soc-2007-maike/source/blender/src/glsl_uniforms.c 2007-07-27 17:45:30 UTC (rev 11394)
@@ -314,31 +314,62 @@
void glsl_update_tree_colorband_uniforms(GLSL_MaterialTree tree)
{
+ GHashIterator *iter = BLI_ghashIterator_new(tree->hash);
+ int i;
+ for(i = 0; i < BLI_ghash_size(tree->hash); i++, BLI_ghashIterator_step(iter)){
+ Material *mat = BLI_ghashIterator_getKey(iter);
+ GLSL_Program shaded = tree->shaded_program;
+ GLSL_Program textured = tree->textured_program;
+
+ while(shaded){
+ glsl_update_material_colorband_uniforms(mat, shaded->program, i);
+ shaded = shaded->next;
+ }
+ }
+
+ BLI_ghashIterator_free(iter);
}
void glsl_update_material_colorband_uniforms(Material *mat, GLuint program, int index)
{
-
+ glsl_update_colorband_uniforms(program, mat, index);
}
void glsl_update_mat_colorband_uniforms(Material *mat)
{
+ GLSL_Material material = BLI_ghash_lookup(matHash, mat);
+ if(material){
+ GHashIterator *iter = BLI_ghashIterator_new(material->parent);
+ int i;
+
+ for(i = 0; i < BLI_ghash_size(material->parent); i++, BLI_ghashIterator_step(iter)){
+ GLSL_MaterialTree tree = BLI_ghashIterator_getKey(iter);
+ int index = tree->mat_index(tree, mat);
+ GLSL_Program shaded = tree->shaded_program;
+ GLSL_Program textured = tree->textured_program;
+
+ glsl_update_colorband_uniforms(shaded->program, mat, index);
+ /* textured missing */
+ }
+
+ BLI_ghashIterator_free(iter);
+ }
}
void glsl_update_colorband_uniforms(GLuint program, Material *mat, int index)
{
char *diff_fac, *spec_fac;
- char *diff_tex, *spec_tex;
GLSL_Material material = BLI_ghash_lookup(matHash, mat);
if(!material) return;
+ glUseProgram(program);
if(mat->mode & MA_RAMP_COL){
GLSL_ColorBand colorband = material->diff_ramp;
@@ -346,35 +377,56 @@
diff_fac = glsl_string(5, 0, "u_mat_", GINT, index, 0, "_ramp_", GINT, 0, 0, "_fac");
glUniform1f(glsl_uniform_location(program, diff_fac), mat->rampfac_col);
+ MEM_freeN(diff_fac);
+ printf("\nGLSL Diffuse Colorband Uniform sent\n");
+ }
+ if(mat->mode & MA_RAMP_SPEC){
+ GLSL_ColorBand colorband = material->spec_ramp;
+
+ spec_fac = glsl_string(5, 0, "u_mat_", GINT, index, 0, "_ramp_", GINT, 1, 0, "_fac");
+ glUniform1f(glsl_uniform_location(program, spec_fac), mat->rampfac_spec);
+
+ MEM_freeN(spec_fac);
+ printf("\nGLSL Specular Colorband Uniform sent\n");
+ }
+
+ glUseProgram(0);
+}
+
+
+void glsl_update_colorband_tex_uniforms(GLuint program, Material *mat, int index)
+{
+ char *diff_tex, *spec_tex;
+
+ GLSL_Material material = BLI_ghash_lookup(matHash, mat);
+
+ if(!material) return;
+
+ if(mat->mode & MA_RAMP_COL){
+ GLSL_ColorBand colorband = material->diff_ramp;
+
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_1D, colorband->texid);
- glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, COLORBAND_WIDTH, 0, GL_RGBA, GL_UNSIGNED_BYTE, colorband->tex);
diff_tex = glsl_string(5, 0, "u_mat_", GINT, index, 0, "_ramp_", GINT, 0, 0, "_tex");
glUniform1i(glsl_uniform_location(program, diff_tex), 1);
glEnable(GL_TEXTURE_1D);
-
-
- MEM_freeN(diff_fac);
+
MEM_freeN(diff_tex);
- printf("\nGLSL Diffuse Colorband Uniform sent\n");
+ printf("\nGLSL Diffuse Colorband Texture sent\n");
}
if(mat->mode & MA_RAMP_SPEC){
GLSL_ColorBand colorband = material->spec_ramp;
- spec_fac = glsl_string(5, 0, "u_mat_", GINT, index, 0, "_ramp_", GINT, 1, 0, "_fac");
- glUniform1f(glsl_uniform_location(program, spec_fac), mat->rampfac_spec);
-
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_1D, colorband->texid);
spec_tex = glsl_string(5, 0, "u_mat_", GINT, index, 0, "_ramp_", GINT, 1, 0, "_tex");
glUniform1i(glsl_uniform_location(program, spec_tex), 2);
glEnable(GL_TEXTURE_1D);
- MEM_freeN(spec_fac);
MEM_freeN(spec_tex);
- printf("\nGLSL Specular Colorband Uniform sent\n");
+ printf("\nGLSL Specular Colorband Texture sent\n");
}
-
+
glActiveTexture(GL_TEXTURE0);
}
More information about the Bf-blender-cvs
mailing list