Revision: 15259
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15259
Author:   blendix
Date:     2008-06-18 01:25:20 +0200 (Wed, 18 Jun 2008)

Log Message:
-----------
Apricot Branch: GLSL
====================

* Added GLSL vertex color support in the game engine.
* Added VCol Paint and VCol Light options.

Modified Paths:
--------------
    branches/apricot/source/blender/blenkernel/intern/DerivedMesh.c
    branches/apricot/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/apricot/source/blender/blenkernel/intern/subsurf_ccg.c
    branches/apricot/source/blender/gpu/GPU_material.h
    branches/apricot/source/blender/gpu/intern/gpu_material.c
    branches/apricot/source/blender/gpu/intern/material_shaders.glsl
    branches/apricot/source/blender/gpu/intern/material_shaders.glsl.c
    branches/apricot/source/gameengine/Converter/BL_BlenderDataConversion.cpp
    branches/apricot/source/gameengine/Ketsji/BL_BlenderShader.cpp
    branches/apricot/source/gameengine/Rasterizer/RAS_IRasterizer.h
    
branches/apricot/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
    
branches/apricot/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp

Modified: branches/apricot/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/apricot/source/blender/blenkernel/intern/DerivedMesh.c     
2008-06-17 22:03:17 UTC (rev 15258)
+++ branches/apricot/source/blender/blenkernel/intern/DerivedMesh.c     
2008-06-17 23:25:20 UTC (rev 15259)
@@ -944,7 +944,9 @@
        }                                                                       
                                                                                
\
        for(b = 0; b < attribs.totmcol; b++) {                                  
                                        \
                MCol *cp = (MCol*)((char*)efa->data + 
attribs.mcol[b].emOffset);                \
-               glVertexAttrib4ubv(attribs.mcol[b].glIndex, 
(GLubyte*)(cp+vert));               \
+               GLubyte col[4];                                                 
                                                                \
+               col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;     
                        \
+               glVertexAttrib4ubv(attribs.mcol[b].glIndex, col);               
                                \
        }                                                                       
                                                                                
\
        if(attribs.tottang) {                                                   
                                                        \
                float *tang = attribs.tang.array[i*4 + vert];                   
                                \

Modified: branches/apricot/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/apricot/source/blender/blenkernel/intern/cdderivedmesh.c   
2008-06-17 22:03:17 UTC (rev 15258)
+++ branches/apricot/source/blender/blenkernel/intern/cdderivedmesh.c   
2008-06-17 23:25:20 UTC (rev 15259)
@@ -658,7 +658,9 @@
        }                                                                       
                                                                        \
        for(b = 0; b < attribs.totmcol; b++) {                                  
                                \
                MCol *cp = &attribs.mcol[b].array[a*4 + vert];                  
                        \
-               glVertexAttrib4ubv(attribs.mcol[b].glIndex, (GLubyte*)cp);      
                \
+               GLubyte col[4];                                                 
                                                        \
+               col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;     
                \
+               glVertexAttrib4ubv(attribs.mcol[b].glIndex, col);               
                        \
        }                                                                       
                                                                        \
        if(attribs.tottang) {                                                   
                                                \
                float *tang = attribs.tang.array[a*4 + vert];                   
                        \

Modified: branches/apricot/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/apricot/source/blender/blenkernel/intern/subsurf_ccg.c     
2008-06-17 22:03:17 UTC (rev 15258)
+++ branches/apricot/source/blender/blenkernel/intern/subsurf_ccg.c     
2008-06-17 23:25:20 UTC (rev 15259)
@@ -1700,7 +1700,9 @@
        }                                                                       
                                                                        \
        for(b = 0; b < attribs.totmcol; b++) {                                  
                                \
                MCol *cp = &attribs.mcol[b].array[a*4 + vert];                  
                        \
-               glVertexAttrib4ubv(attribs.mcol[b].glIndex, (GLubyte*)cp);      
                \
+               GLubyte col[4];                                                 
                                                        \
+               col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;     
                \
+               glVertexAttrib4ubv(attribs.mcol[b].glIndex, col);               
                        \
        }                                                                       
                                                                        \
        if(attribs.tottang) {                                                   
                                                \
                float *tang = attribs.tang.array[a*4 + vert];                   
                        \

Modified: branches/apricot/source/blender/gpu/GPU_material.h
===================================================================
--- branches/apricot/source/blender/gpu/GPU_material.h  2008-06-17 22:03:17 UTC 
(rev 15258)
+++ branches/apricot/source/blender/gpu/GPU_material.h  2008-06-17 23:25:20 UTC 
(rev 15259)
@@ -111,7 +111,7 @@
        GPUMaterial *gpumat;
        struct Material *mat;
 
-       GPUNodeLink *rgb, *specrgb, *vn, *view;
+       GPUNodeLink *rgb, *specrgb, *vn, *view, *vcol;
        GPUNodeLink *alpha, *refl, *spec, *emit, *har, *amb;
 } GPUShadeInput;
 

Modified: branches/apricot/source/blender/gpu/intern/gpu_material.c
===================================================================
--- branches/apricot/source/blender/gpu/intern/gpu_material.c   2008-06-17 
22:03:17 UTC (rev 15258)
+++ branches/apricot/source/blender/gpu/intern/gpu_material.c   2008-06-17 
23:25:20 UTC (rev 15259)
@@ -842,15 +842,23 @@
        GPU_link(mat, "set_value", GPU_uniform(&hard), &shi->har);
        GPU_link(mat, "set_value", GPU_uniform(&ma->amb), &shi->amb);
        GPU_link(mat, "shade_view", &shi->view);
+       GPU_link(mat, "vcol_attribute", GPU_attribute(CD_MCOL, ""), &shi->vcol);
 }
 
 void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr)
 {
        Material *ma= shi->mat;
        GPUMaterial *mat= shi->gpumat;
+       GPUNodeLink *emit;
 
        memset(shr, 0, sizeof(*shr));
 
+       if(ma->mode & (MA_VERTEXCOLP/*|MA_FACETEXTURE*/)) {
+               shi->rgb = shi->vcol;
+               /*if(ma->mode & (MA_FACETEXTURE_ALPHA))
+                       GPU_link(mat, "mtex_alpha_from_col", shi->vcol, 
&shi->alpha);*/
+       }
+
        do_material_tex(shi);
 
        if(ma->alpha < 1.0f)
@@ -861,7 +869,13 @@
                shr->alpha = shi->alpha;
        }
        else {
-               GPU_link(mat, "shade_mul_value", shi->emit, shi->rgb, 
&shr->diff);
+               if((ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL) {
+                       GPU_link(mat, "shade_add", shi->emit, shi->vcol, &emit);
+                       GPU_link(mat, "shade_mul", emit, shi->rgb, &shr->diff);
+               }
+               else
+                       GPU_link(mat, "shade_mul_value", shi->emit, shi->rgb, 
&shr->diff);
+
                GPU_link(mat, "set_rgb_zero", &shr->spec);
 
                material_lights(shi, shr);

Modified: branches/apricot/source/blender/gpu/intern/material_shaders.glsl
===================================================================
--- branches/apricot/source/blender/gpu/intern/material_shaders.glsl    
2008-06-17 22:03:17 UTC (rev 15258)
+++ branches/apricot/source/blender/gpu/intern/material_shaders.glsl    
2008-06-17 23:25:20 UTC (rev 15259)
@@ -7,6 +7,8 @@
 
 /************** COMMON ****************/
 
+#define M_PI 3.14159265358979323846
+
 void rgb_to_hsv(vec4 rgb, out vec4 outcol)
 {
        float cmax, cmin, h, s, v, cdelta;
@@ -80,16 +82,24 @@
 
 /*********** SHADER NODES ***************/
 
-#define M_PI 3.14159265358979323846
+void vcol_attribute(vec4 attvcol, out vec4 vcol)
+{
+       vcol = vec4(attvcol.x/255.0, attvcol.y/255.0, attvcol.z/255.0, 1.0);
+}
 
+void uv_attribute(vec2 attuv, out vec3 uv)
+{
+       uv = vec3(attuv*2.0 - vec2(1.0, 1.0), 0.0);
+}
+
 void geom(vec3 attorco, vec2 attuv, vec4 attvcol, out vec3 global, out vec3 
local, out vec3 view, out vec3 orco, out vec3 uv, out vec3 normal, out vec4 
vcol, out float frontback)
 {
        local = varcamco;
        view = normalize(local);
        orco = attorco;
-       uv = vec3(attuv*2.0 - vec2(1.0, 1.0), 0.0);
+       uv_attribute(attuv, uv);
        normal = -normalize(varnormal); /* blender render normal is negated */
-       vcol = vec4(attvcol.w/255.0, attvcol.z/255.0, attvcol.y/255.0, 1.0);
+       vcol_attribute(attvcol, vcol);
        frontback = 1.0;
 }
 
@@ -927,7 +937,7 @@
        har *= 128.0;
 
        if(har < 1.0) outhar = 1.0;
-       else if(har > 511.0) outhar = 511;
+       else if(har > 511.0) outhar = 511.0;
        else outhar = har;
 }
 
@@ -1449,6 +1459,11 @@
        outcol = col + col1*col2;
 }
 
+void shade_mul(vec4 col1, vec4 col2, out vec4 outcol)
+{
+       outcol = col1*col2;
+}
+
 void shade_mul_value(float fac, vec4 col, out vec4 outcol)
 {
        outcol = col*fac;

Modified: branches/apricot/source/blender/gpu/intern/material_shaders.glsl.c
===================================================================
--- branches/apricot/source/blender/gpu/intern/material_shaders.glsl.c  
2008-06-17 22:03:17 UTC (rev 15258)
+++ branches/apricot/source/blender/gpu/intern/material_shaders.glsl.c  
2008-06-17 23:25:20 UTC (rev 15259)
@@ -1,957 +1,964 @@
 /* DataToC output of file <material_shaders_glsl> */
 
-int datatoc_material_shaders_glsl_size= 31352;
+int datatoc_material_shaders_glsl_size= 31568;
 char datatoc_material_shaders_glsl[]= {
- 10,118, 97,114,121,105,110,103, 32,118,101, 99, 51, 32,118, 97,114, 99,111, 
59, 10,118, 97,114,
-121,105,110,103, 32,118,101, 99, 51, 32,118, 97,114, 99, 97,109, 99,111, 59, 
10,118, 97,114,121,105,110,103, 32,118,101, 99, 51,
- 32,118, 97,114,110,111,114,109, 97,108, 59, 10,117,110,105,102,111,114,109, 
32,109, 97,116, 52, 32,117,110,102,111, 98,109, 97,
-116, 59, 10,117,110,105,102,111,114,109, 32,109, 97,116, 52, 
32,117,110,102,118,105,101,119,109, 97,116, 59, 10, 10, 47, 42, 42,
- 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 67, 79, 77, 77, 79, 78, 
32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
- 42, 42, 42, 42, 47, 10, 10,118,111,105,100, 32,114,103, 98, 95,116,111, 
95,104,115,118, 40,118,101, 99, 52, 32,114,103, 98, 44,
- 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 
10,  9,102,108,111, 97,116, 32, 99,109, 97,120, 44,
- 32, 99,109,105,110, 44, 32,104, 44, 32,115, 44, 32,118, 44, 32, 
99,100,101,108,116, 97, 59, 10,  9,118,101, 99, 51, 32, 99, 59,
- 10, 10,  9, 99,109, 97,120, 32, 61, 32,109, 97,120, 40,114,103, 98, 91, 48, 
93, 44, 32,109, 97,120, 40,114,103, 98, 91, 49, 93,
- 44, 32,114,103, 98, 91, 50, 93, 41, 41, 59, 10,  9, 99,109,105,110, 32, 61, 
32,109,105,110, 40,114,103, 98, 91, 48, 93, 44, 32,
-109,105,110, 40,114,103, 98, 91, 49, 93, 44, 32,114,103, 98, 91, 50, 93, 41, 
41, 59, 10,  9, 99,100,101,108,116, 97, 32, 61, 32,
- 99,109, 97,120, 45, 99,109,105,110, 59, 10, 10,  9,118, 32, 61, 32, 99,109, 
97,120, 59, 10,  9,105,102, 32, 40, 99,109, 97,120,
- 33, 61, 48, 46, 48, 41, 10,  9,  9,115, 32, 61, 32, 99,100,101,108,116, 97, 
47, 99,109, 97,120, 59, 10,  9,101,108,115,101, 32,
-123, 10,  9,  9,115, 32, 61, 32, 48, 46, 48, 59, 10,  9,  9,104, 32, 61, 32, 
48, 46, 48, 59, 10,  9,125, 10, 10,  9,105,102, 32,
- 40,115, 32, 61, 61, 32, 48, 46, 48, 41, 32,123, 10,  9,  9,104, 32, 61, 32, 
48, 46, 48, 59, 10,  9,125, 10,  9,101,108,115,101,
- 32,123, 10,  9,  9, 99, 32, 61, 32, 40,118,101, 99, 51, 40, 99,109, 97,120, 
44, 32, 99,109, 97,120, 44, 32, 99,109, 97,120, 41,
- 32, 45, 32,114,103, 98, 46,120,121,122, 41, 47, 99,100,101,108,116, 97, 59, 
10, 10,  9,  9,105,102, 32, 40,114,103, 98, 46,120,
- 61, 61, 99,109, 97,120, 41, 32,104, 32, 61, 32, 99, 91, 50, 93, 32, 45, 32, 
99, 91, 49, 93, 59, 10,  9,  9,101,108,115,101, 32,
-105,102, 32, 40,114,103, 98, 46,121, 61, 61, 99,109, 97,120, 41, 32,104, 32, 
61, 32, 50, 46, 48, 32, 43, 32, 99, 91, 48, 93, 32,
- 45, 32, 32, 99, 91, 50, 93, 59, 10,  9,  9,101,108,115,101, 32,104, 32, 61, 
32, 52, 46, 48, 32, 43, 32, 99, 91, 49, 93, 32, 45,
- 32, 99, 91, 48, 93, 59, 10, 10,  9,  9,104, 32, 47, 61, 32, 54, 46, 48, 59, 
10, 10,  9,  9,105,102, 32, 40,104, 60, 48, 46, 48,
- 41, 10,  9,  9,  9,104, 32, 43, 61, 32, 49, 46, 48, 59, 10,  9,125, 10, 10,  
9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99,
- 52, 40,104, 44, 32,115, 44, 32,118, 44, 32,114,103, 98, 46,119, 41, 59, 
10,125, 10, 10,118,111,105,100, 32,104,115,118, 95,116,
-111, 95,114,103, 98, 40,118,101, 99, 52, 32,104,115,118, 44, 32,111,117,116, 
32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41,
- 10,123, 10,  9,102,108,111, 97,116, 32,105, 44, 32,102, 44, 32,112, 44, 
32,113, 44, 32,116, 44, 32,104, 44, 32,115, 44, 32,118,
- 59, 10,  9,118,101, 99, 51, 32,114,103, 98, 59, 10, 10,  9,104, 32, 61, 
32,104,115,118, 91, 48, 93, 59, 10,  9,115, 32, 61, 32,

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to