[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11591] branches/soc-2007-maike/source/ blender: Texture uniforms sending
Miguel Torres Lima
torreslima at gmail.com
Tue Aug 14 17:44:29 CEST 2007
Revision: 11591
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11591
Author: maike
Date: 2007-08-14 17:44:29 +0200 (Tue, 14 Aug 2007)
Log Message:
-----------
Texture uniforms sending
Modified Paths:
--------------
branches/soc-2007-maike/source/blender/include/BIF_glsl_uniforms.h
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-08-14 12:35:00 UTC (rev 11590)
+++ branches/soc-2007-maike/source/blender/include/BIF_glsl_uniforms.h 2007-08-14 15:44:29 UTC (rev 11591)
@@ -5,6 +5,8 @@
struct Object;
struct Lamp;
struct GHash;
+struct MTex;
+struct Tex;
/* ------------------------------------------------ */
@@ -53,6 +55,36 @@
#endif
+/* ------------------------------------- TEXTURE ------------------------------------- */
+
+void glsl_update_all_texture_uniforms(void);
+void glsl_update_tree_texture_uniforms(struct GLSL_MaterialTree_ *tree);
+void glsl_update_material_texture_uniforms(struct Material *mat, struct GLSL_Program_ *program, int index);
+void glsl_update_mat_texture_uniforms(struct Material *mat);
+
+#ifdef __APPLE__
+void glsl_update_texture_uniforms(unsigned long program, struct MTex *mtex, int texindex, int matindex);
+#else
+void glsl_update_texture_uniforms(unsigned int program, struct MTex *mtex, int texindex, int matindex);
+#endif
+
+void glsl_update_texture_clouds_uniforms(struct Tex *tex, int texindex, int matindex);
+void glsl_update_texture_wood_uniforms(struct Tex *tex, int texindex, int matindex);
+void glsl_update_texture_marble_uniforms(struct Tex *tex, int texindex, int matindex);
+void glsl_update_texture_magic_uniforms(struct Tex *tex, int texindex, int matindex);
+void glsl_update_texture_blend_uniforms(struct Tex *tex, int texindex, int matindex);
+void glsl_update_texture_stucci_uniforms(struct Tex *tex, int texindex, int matindex);
+void glsl_update_texture_noise_uniforms(struct Tex *tex, int texindex, int matindex);
+void glsl_update_texture_image_uniforms(struct Tex *tex, int texindex, int matindex);
+void glsl_update_texture_plugin_uniforms(struct Tex *tex, int texindex, int matindex);
+void glsl_update_texture_envmap_uniforms(struct Tex *tex, int texindex, int matindex);
+void glsl_update_texture_musgrave_uniforms(struct Tex *tex, int texindex, int matindex);
+void glsl_update_texture_voronoi_uniforms(struct Tex *tex, int texindex, int matindex);
+void glsl_update_texture_distnoise_uniforms(struct Tex *tex, int texindex, int matindex);
+
+
+/* -------------------------------------- LIGHT -------------------------------------- */
+
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_uniforms.c
===================================================================
--- branches/soc-2007-maike/source/blender/src/glsl_uniforms.c 2007-08-14 12:35:00 UTC (rev 11590)
+++ branches/soc-2007-maike/source/blender/src/glsl_uniforms.c 2007-08-14 15:44:29 UTC (rev 11591)
@@ -47,6 +47,7 @@
/* --------------------------------------------------------------------------- */
+
void glsl_update_all_material_uniforms(void)
{
GHashIterator *iter = BLI_ghashIterator_new(treeHash);
@@ -446,6 +447,252 @@
}
+/* --------------------- TEXTURES ------------------------ */
+
+void glsl_update_all_texture_uniforms(void)
+{
+ GHashIterator *iter = BLI_ghashIterator_new(treeHash);
+ int i;
+
+ for(i = 0; i < BLI_ghash_size(treeHash); i++, BLI_ghashIterator_step(iter)){
+ GLSL_MaterialTree tree = BLI_ghashIterator_getValue(iter);
+
+ glsl_update_tree_texture_uniforms(tree);
+ }
+
+ BLI_ghashIterator_free(iter);
+}
+
+
+void glsl_update_tree_texture_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 program = tree->shaded_program;
+
+ while(program){
+ glsl_update_material_texture_uniforms(mat, program, i);
+ program = program->next;
+ }
+ }
+
+ BLI_ghashIterator_free(iter);
+}
+
+
+void glsl_update_material_texture_uniforms(Material *mat, GLSL_Program program, int index)
+{
+ int i;
+
+ for(i = 0; i < MAX_MTEX; i++){
+ MTex *mtex = mat->mtex[i];
+
+ if(mtex && mtex->tex && mtex->tex->type){
+ glsl_update_texture_uniforms(program->program, mtex, i, index);
+ }
+ }
+}
+
+
+void glsl_update_mat_texture_uniforms(Material *mat)
+{
+ GLSL_Material material = BLI_ghash_lookup(matHash, mat);
+
+ if(material){
+ GHashIterator *iter = BLI_ghashIterator_new(material->parent);
+ int i, index;
+
+ for(i = 0; i < BLI_ghash_size(material->parent); i++, BLI_ghashIterator_step(iter)){
+ GLSL_MaterialTree tree = BLI_ghashIterator_getKey(iter);
+ GLSL_Program program = tree->shaded_program;
+
+ index = tree->mat_index(tree, mat);
+
+ while(program){
+ glsl_update_material_texture_uniforms(mat, program, index);
+ program = program->next;
+ }
+ }
+
+ BLI_ghashIterator_free(iter);
+ }
+}
+
+
+void glsl_update_texture_uniforms(GLuint program, MTex *mtex, int texindex, int matindex)
+{
+ char *ofs = glsl_string(5, 0, "uniform vec3 mat_", GINT, matindex, 0, "_tex_", GINT, texindex, 0, "_ofs;\n");
+ char *size = glsl_string(5, 0, "uniform vec3 mat_", GINT, matindex, 0, "_tex_", GINT, texindex, 0, "_size;\n");
+ char *colfac = glsl_string(5, 0, "uniform float mat_", GINT, matindex, 0, "_tex_", GINT, texindex, 0, "_colfac;\n");
+ char *norfac = glsl_string(5, 0, "uniform float mat_", GINT, matindex, 0, "_tex_", GINT, texindex, 0, "_norfac;\n");
+ char *varfac = glsl_string(5, 0, "uniform float mat_", GINT, matindex, 0, "_tex_", GINT, texindex, 0, "_varfac;\n");
+ char *warpfac = glsl_string(5, 0, "uniform float mat_", GINT, matindex, 0, "_tex_", GINT, texindex, 0, "_warpfac;\n");
+ char *neg = glsl_string(5, 0, "uniform float mat_", GINT, matindex, 0, "_tex_", GINT, texindex, 0, "_neg;\n");
+ char *norgb = glsl_string(5, 0, "uniform float mat_", GINT, matindex, 0, "_tex_", GINT, texindex, 0, "_norgb;\n");
+ char *norgbcol = glsl_string(5, 0, "uniform vec3 mat_", GINT, matindex, 0, "_tex_", GINT, texindex, 0, "_norgbcol;\n");
+ char *dvarfac = glsl_string(5, 0, "uniform float mat_", GINT, matindex, 0, "_tex_", GINT, texindex, 0, "_dvarfac;\n");
+
+ Tex *tex = mtex->tex;
+
+ glUseProgram(program);
+
+ glUniform3f(glsl_uniform_location(program, ofs), mtex->ofs[0], mtex->ofs[1], mtex->ofs[2]);
+ glUniform3f(glsl_uniform_location(program, size), mtex->size[0], mtex->size[1], mtex->size[2]);
+ glUniform1f(glsl_uniform_location(program, colfac), mtex->colfac);
+ glUniform1f(glsl_uniform_location(program, norfac), mtex->norfac);
+ glUniform1f(glsl_uniform_location(program, varfac), mtex->varfac);
+ glUniform1f(glsl_uniform_location(program, warpfac), mtex->warpfac);
+ glUniform1f(glsl_uniform_location(program, neg), (mtex->texflag & MTEX_NEGATIVE)?1.0:0.0);
+ glUniform1f(glsl_uniform_location(program, norgb), (mtex->texflag & MTEX_RGBTOINT)?1.0:0.0);
+ glUniform3f(glsl_uniform_location(program, norgbcol), mtex->r, mtex->g, mtex->b);
+ glUniform1f(glsl_uniform_location(program, dvarfac), mtex->def_var);
+
+
+ switch(tex->type)
+ {
+ case TEX_CLOUDS:
+ glsl_update_texture_clouds_uniforms(tex, texindex, matindex);
+ break;
+ case TEX_WOOD:
+ glsl_update_texture_wood_uniforms(tex, texindex, matindex);
+ break;
+ case TEX_MARBLE:
+ glsl_update_texture_marble_uniforms(tex, texindex, matindex);
+ break;
+ case TEX_MAGIC:
+ glsl_update_texture_magic_uniforms(tex, texindex, matindex);
+ break;
+ case TEX_BLEND:
+ glsl_update_texture_blend_uniforms(tex, texindex, matindex);
+ break;
+ case TEX_STUCCI:
+ glsl_update_texture_stucci_uniforms(tex, texindex, matindex);
+ break;
+ case TEX_NOISE:
+ glsl_update_texture_noise_uniforms(tex, texindex, matindex);
+ break;
+ case TEX_IMAGE:
+ glsl_update_texture_image_uniforms(tex, texindex, matindex);
+ break;
+ case TEX_PLUGIN:
+ glsl_update_texture_plugin_uniforms(tex, texindex, matindex);
+ break;
+ case TEX_ENVMAP:
+ glsl_update_texture_envmap_uniforms(tex, texindex, matindex);
+ break;
+ case TEX_MUSGRAVE:
+ glsl_update_texture_musgrave_uniforms(tex, texindex, matindex);
+ break;
+ case TEX_VORONOI:
+ glsl_update_texture_voronoi_uniforms(tex, texindex, matindex);
+ break;
+ case TEX_DISTNOISE:
+ glsl_update_texture_distnoise_uniforms(tex, texindex, matindex);
+ break;
+ }
+
+
+ MEM_freeN(ofs);
+ MEM_freeN(size);
+ MEM_freeN(colfac);
+ MEM_freeN(norfac);
+ MEM_freeN(varfac);
+ MEM_freeN(warpfac);
+ MEM_freeN(neg);
+ MEM_freeN(norgb);
+ MEM_freeN(norgbcol);
+ MEM_freeN(dvarfac);
+
+ glUseProgram(0);
+}
+
+
+void glsl_update_texture_clouds_uniforms(Tex *tex, int texindex, int matindex)
+{
+
+}
+
+
+void glsl_update_texture_wood_uniforms(Tex *tex, int texindex, int matindex)
+{
+
+}
+
+
+void glsl_update_texture_marble_uniforms(Tex *tex, int texindex, int matindex)
+{
+
+}
+
+
+void glsl_update_texture_magic_uniforms(Tex *tex, int texindex, int matindex)
+{
+
+}
+
+
+void glsl_update_texture_blend_uniforms(Tex *tex, int texindex, int matindex)
+{
+
+}
+
+
+void glsl_update_texture_stucci_uniforms(Tex *tex, int texindex, int matindex)
+{
+
+}
+
+
+void glsl_update_texture_noise_uniforms(Tex *tex, int texindex, int matindex)
+{
+
+}
+
+
+void glsl_update_texture_image_uniforms(Tex *tex, int texindex, int matindex)
+{
+
+}
+
+
+void glsl_update_texture_plugin_uniforms(Tex *tex, int texindex, int matindex)
+{
+
+}
+
+
+void glsl_update_texture_envmap_uniforms(Tex *tex, int texindex, int matindex)
+{
+
+}
+
+
+void glsl_update_texture_musgrave_uniforms(Tex *tex, int texindex, int matindex)
+{
+
+}
+
+
+void glsl_update_texture_voronoi_uniforms(Tex *tex, int texindex, int matindex)
+{
+
+}
+
+
+void glsl_update_texture_distnoise_uniforms(Tex *tex, int texindex, int matindex)
+{
+
+}
+
+
+
+
+
+/* ---------------------- LIGHTS ------------------------- */
+
void glsl_update_all_light_uniforms(GLSL_MaterialTree tree)
{
GLSL_List list = lights;
More information about the Bf-blender-cvs
mailing list