[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11045] branches/soc-2007-maike/source/ blender: GLSL Material preview base:
Miguel Torres Lima
torreslima at gmail.com
Mon Jun 25 19:56:21 CEST 2007
Revision: 11045
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11045
Author: maike
Date: 2007-06-25 19:56:21 +0200 (Mon, 25 Jun 2007)
Log Message:
-----------
GLSL Material preview base:
+ Rewrote glsl material and light structures
+ Added GLSL_MaterialTree struct and functions for its creation, deletion
+ Added GLSL_Program struct and functions for creation, deletion.
+ Added glsl code generation for solid mode
+ Added glsl generic function files to release/glsl
+ Added button "GLSL Preview" to user preferences
Modified Paths:
--------------
branches/soc-2007-maike/source/blender/blenkernel/intern/blender.c
branches/soc-2007-maike/source/blender/blenkernel/intern/material.c
branches/soc-2007-maike/source/blender/blenkernel/intern/scene.c
branches/soc-2007-maike/source/blender/include/BIF_glsl_light.h
branches/soc-2007-maike/source/blender/include/BIF_glsl_material.h
branches/soc-2007-maike/source/blender/include/BIF_glsl_program.h
branches/soc-2007-maike/source/blender/include/BIF_glsl_util.h
branches/soc-2007-maike/source/blender/include/BIF_glutil.h
branches/soc-2007-maike/source/blender/include/butspace.h
branches/soc-2007-maike/source/blender/src/butspace.c
branches/soc-2007-maike/source/blender/src/buttons_shading.c
branches/soc-2007-maike/source/blender/src/drawobject.c
branches/soc-2007-maike/source/blender/src/editobject.c
branches/soc-2007-maike/source/blender/src/editscreen.c
branches/soc-2007-maike/source/blender/src/glsl_light.c
branches/soc-2007-maike/source/blender/src/glsl_material.c
branches/soc-2007-maike/source/blender/src/glsl_program.c
branches/soc-2007-maike/source/blender/src/glsl_util.c
branches/soc-2007-maike/source/blender/src/glutil.c
branches/soc-2007-maike/source/blender/src/header_view3d.c
branches/soc-2007-maike/source/blender/src/headerbuttons.c
branches/soc-2007-maike/source/blender/src/usiblender.c
Added Paths:
-----------
branches/soc-2007-maike/source/blender/include/BIF_glsl_drawobject.h
branches/soc-2007-maike/source/blender/include/BIF_glsl_material_node.h
branches/soc-2007-maike/source/blender/include/BIF_glsl_node_util.h
branches/soc-2007-maike/source/blender/include/BIF_glsl_shader_util.h
branches/soc-2007-maike/source/blender/src/glsl_drawobject.c
branches/soc-2007-maike/source/blender/src/glsl_material_node.c
branches/soc-2007-maike/source/blender/src/glsl_node_util.c
branches/soc-2007-maike/source/blender/src/glsl_shader_util.c
Modified: branches/soc-2007-maike/source/blender/blenkernel/intern/blender.c
===================================================================
--- branches/soc-2007-maike/source/blender/blenkernel/intern/blender.c 2007-06-25 17:51:37 UTC (rev 11044)
+++ branches/soc-2007-maike/source/blender/blenkernel/intern/blender.c 2007-06-25 17:56:21 UTC (rev 11045)
@@ -89,6 +89,10 @@
#include "nla.h"
#include "blendef.h"
+#include "BIF_glutil.h"
+#include "BIF_glsl_material.h"
+
+
Global G;
UserDef U;
@@ -358,9 +362,9 @@
U= *bfd->user;
MEM_freeN(bfd->user);
-
}
-
+
+
/* samples is a global list... */
sound_free_all_samples();
Modified: branches/soc-2007-maike/source/blender/blenkernel/intern/material.c
===================================================================
--- branches/soc-2007-maike/source/blender/blenkernel/intern/material.c 2007-06-25 17:51:37 UTC (rev 11044)
+++ branches/soc-2007-maike/source/blender/blenkernel/intern/material.c 2007-06-25 17:56:21 UTC (rev 11045)
@@ -65,6 +65,7 @@
#include "BPY_extern.h"
#include "BIF_glsl_material.h"
+#include "BIF_glutil.h"
/* used in UI and render */
Material defmaterial;
@@ -72,9 +73,10 @@
/* called on startup, creator.c */
void init_def_material(void)
{
- glsl_init_ghash();
init_material(&defmaterial);
- glsl_init_def_material(&defmaterial);
+
+ glsl_init_ghash();
+ glsl_init_defmaterial(&defmaterial);
}
/* not material itself */
@@ -103,7 +105,8 @@
MEM_freeN(ma->nodetree);
}
- glsl_delete_material(ma);
+ if(glsl_active() != 0 && ma != &defmaterial)
+ glsl_delete_material(ma);
}
void init_material(Material *ma)
@@ -165,10 +168,6 @@
ma->sss_back= 1.0f;
ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RADIO|MA_RAYBIAS|MA_TANGENT_STR;
-
- if(ma != &defmaterial)
- glsl_create_material(ma, GLSL_HASH, NULL);
-
}
Material *add_material(char *name)
@@ -178,6 +177,10 @@
ma= alloc_libblock(&G.main->mat, ID_MA, name);
init_material(ma);
+
+ if(ma != &defmaterial && glsl_active() != 0)
+ glsl_create_materialtree(ma, GLSL_MAT);
+
return ma;
}
@@ -208,9 +211,10 @@
if(ma->nodetree) {
man->nodetree= ntreeCopyTree(ma->nodetree, 0); /* 0 == full new tree */
}
-
- glsl_create_material(man, GLSL_HASH, NULL);
+ if(glsl_active() != 0 && ma != &defmaterial)
+ glsl_create_materialtree(man, GLSL_MAT);
+
return man;
}
@@ -830,8 +834,11 @@
/* we delete the actcol */
if(ob->totcol) {
- mao= (*matarar)[ob->actcol-1];
- if(mao) mao->id.us--;
+ mao= (*matarar)[ob->actcol-1];
+ if(mao){
+ /*glsl_delete_material_index(mao);*/
+ mao->id.us--;
+ }
}
for(a=ob->actcol; a<ob->totcol; a++) {
@@ -886,6 +893,7 @@
}
freedisplist(&ob->disp);
}
+
}
Modified: branches/soc-2007-maike/source/blender/blenkernel/intern/scene.c
===================================================================
--- branches/soc-2007-maike/source/blender/blenkernel/intern/scene.c 2007-06-25 17:51:37 UTC (rev 11044)
+++ branches/soc-2007-maike/source/blender/blenkernel/intern/scene.c 2007-06-25 17:56:21 UTC (rev 11045)
@@ -87,6 +87,7 @@
#include "BIF_glsl_light.h"
#include "BIF_glsl_util.h"
+#include "BIF_glutil.h"
#include "nla.h"
@@ -273,7 +274,9 @@
G.scene= sce;
- glsl_free_structs();
+ if(glsl_active() != 0){
+ glsl_free_all();
+ }
/* check for cyclic sets, for reading old files but also for definite security (py?) */
scene_check_setscene(G.scene);
@@ -315,10 +318,14 @@
ob->ctime= -1234567.0; /* force ipo to be calculated later */
- if(ob->type == OB_LAMP)
+ /*if(ob->type == OB_LAMP && glsl_active != 0)
glsl_init_scene_light(ob->data, ob);
- else if(G.scene->lay & base->lay) glsl_query_material(ob);
+ else if(G.scene->lay & base->lay && glsl_active() != 0) glsl_query_material(ob);*/
}
+
+ if(glsl_active() != 0)
+ glsl_create_all();
+
/* no full animation update, this to enable render code to work (render code calls own animation updates) */
/* do we need FRAMECHANGED in set_scene? */
// if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_FRAMECHANGED);
Added: branches/soc-2007-maike/source/blender/include/BIF_glsl_drawobject.h
===================================================================
--- branches/soc-2007-maike/source/blender/include/BIF_glsl_drawobject.h (rev 0)
+++ branches/soc-2007-maike/source/blender/include/BIF_glsl_drawobject.h 2007-06-25 17:56:21 UTC (rev 11045)
@@ -0,0 +1,26 @@
+struct Base;
+struct Object;
+struct MVert;
+struct MCol;
+struct Object;
+struct MFace;
+struct MVert;
+
+/* ----------------------------------------------------------------------------- */
+
+typedef struct {
+ DerivedMesh dm;
+ MVert *mvert;
+ MEdge *medge;
+ MFace *mface;
+} CDDerivedMesh;
+
+/* ----------------------------------------------------------------------------- */
+
+void light_uniforms(unsigned int program, struct Object *obj);
+void create_vertex(struct Object *obj, struct MVert *vert, int index, int flag);
+void glsl_draw(struct Base *base);
+void set_vertex_color(struct Material *mat, struct MCol *mcol, int n, unsigned int program);
+void glsl_set_outline_colors(void);
+void glsl_draw_outline(struct Base *base, struct MFace *face, int num, struct MVert *vert);
+void glsl_draw_mesh_selected_outline(struct MFace *face, int num, struct MVert *vert);
Modified: branches/soc-2007-maike/source/blender/include/BIF_glsl_light.h
===================================================================
--- branches/soc-2007-maike/source/blender/include/BIF_glsl_light.h 2007-06-25 17:51:37 UTC (rev 11044)
+++ branches/soc-2007-maike/source/blender/include/BIF_glsl_light.h 2007-06-25 17:56:21 UTC (rev 11045)
@@ -1,116 +1,44 @@
-typedef struct GLSL_LightList_ *GLSL_LightList;
-typedef struct GLSL_Light_ *GLSL_Light;
-typedef struct GLSL_LampLight_ *GLSL_LampLight;
-typedef struct GLSL_AreaLight_ *GLSL_AreaLight;
-typedef struct GLSL_SpotLight_ *GLSL_SpotLight;
-typedef struct GLSL_SunLight_ *GLSL_SunLight;
-typedef struct GLSL_HemiLight_ *GLSL_HemiLight;
-typedef struct GLSL_LocalLight_ *GLSL_LocalLight;
-
-struct GLSL_LightList_
-{
- GLSL_Light light;
- GLSL_LightList next, prev;
-};
-
-
struct GLSL_Light_
{
- short type; // lamp type flag
- void *glsl_light; // pointer to GLSL_Lamp... type structure
- void *blen_light; // pointer to Blender light
-};
+ short type; /* lamp type flag */
+ short mode; /* lamp specular | diffuse flag */
+ void *blen_light; /* pointer to blender light */
-
-struct GLSL_LampLight_
-{
- short mode; // light's active modes LA_QUAD | LA_SPHERE | LA_LAYER | LA_NEG | LA_NO_DIFF | LA_NO_SPEC
-
- float loc[3]; // light's location
- float color[3]; // light's diffuse color
- float dist; // light's distance parameter
- float energy; // light's energy
- float quad1; // light's linear distance attenuation factor
- float quad2; // light's quadratic distance attenuation factor
+ struct Object *obj;
};
-struct GLSL_AreaLight_
-{
- short mode;
+/* -------------------------------------------------------- */
- float loc[3];
- float color[3]; // directional light's directional vector
- float dist;
- float energy;
- float gamma; // area light's gamma
+typedef struct GLSL_Light_ *GLSL_Light;
- short area_type; // area type square | rectangle
- float area_size_x; // area's x size (x and y for square)
- float area_size_y; // area's y size (only for rectangle)
-};
+/* -------------------------------------------------------- */
-
-struct GLSL_SpotLight_
-{
- short mode;
-
- float loc[3];
- float color[3];
- float dist;
- float energy;
- float quad1;
- float quad2;
-};
-
-
-struct GLSL_SunLight_
-{
- short mode;
-
- float loc[3];
- float vec[3];
- float color[3];
- float dist;
- float energy;
-};
-
-
-struct GLSL_HemiLight_
-{
- short mode;
-
- float loc[3];
- float vec[3];
- float color[3];
- float dist;
- float energy;
-};
-
-
-struct GLSL_LocalLight_
-{
- float vec[3];
- float color[3];
- float spec_color[3];
-};
-
-
struct Lamp;
struct Object;
+struct GLSL_List_;
+struct GLSL_MaterialTree_;
+/* -------------------------------------------------------- */
+
int glsl_get_num_lights(void);
-GLSL_LightList glsl_get_lights(void);
+struct GLSL_List_ * glsl_get_lights(void);
void glsl_init_scene_light(struct Lamp *lamp, struct Object *obj);
void glsl_free_light_structs(void);
void glsl_create_light(struct Lamp *lamp, struct Object *obj);
+struct GLSL_List_ * glsl_get_light(struct Lamp *lamp);
+
+void glsl_update_light(struct Lamp *lamp, unsigned short event);
+
+void glsl_update_all_light_uniforms(struct GLSL_MaterialTree_ *tree);
+void glsl_update_light_uniforms(GLSL_Light light, struct Lamp *lamp, struct GLSL_MaterialTree_ *vtree);
+
+int glsl_get_light_num(struct Lamp *lamp);
GLSL_Light glsl_create_glsl_light(struct Lamp *lamp, struct Object *obj);
-GLSL_LampLight create_lamp_light(struct Lamp *lamp, struct Object *obj);
-GLSL_AreaLight create_area_light(struct Lamp *lamp, struct Object *obj);
-GLSL_SpotLight create_spot_light(struct Lamp *lamp, struct Object *obj);
-GLSL_SunLight create_sun_light(struct Lamp *lamp, struct Object *obj);
-GLSL_HemiLight create_hemi_light(struct Lamp *lamp, struct Object *obj);
+
+int glsl_check_param(short attr1, short attr2, int param);
+
void glsl_delete_light(struct Lamp *lamp);
-void glsl_delete_glsl_light(GLSL_Light light);
+
Modified: branches/soc-2007-maike/source/blender/include/BIF_glsl_material.h
===================================================================
--- branches/soc-2007-maike/source/blender/include/BIF_glsl_material.h 2007-06-25 17:51:37 UTC (rev 11044)
+++ branches/soc-2007-maike/source/blender/include/BIF_glsl_material.h 2007-06-25 17:56:21 UTC (rev 11045)
@@ -1,44 +1,87 @@
#define GLSL_HASH 0 /* used to decide which hash is used, a global or a local hash */
#define GLSL_LOCALHASH 1
+#define GLSL_MAT 0
+#define GLSL_NODES 1
+
+/* ------------------------------------------------ */
+
struct GLSL_Program_;
struct Material;
struct Object;
struct GHash;
+/* ------------------------------------------------ */
+struct GLSL_Material_
+{
+ struct Material *mat;
+ struct GHash *parent;
-/* GLSL Material - structure used for materials control used by GLSL */
+ short num_parents;
+ short diffuse_shader;
+ short specular_shader;
+ short texface;
-typedef struct GLSL_Material_ *GLSL_Material;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list