Merge with trunk r41342
[blender-staging.git] / source / blender / render / intern / source / shadeoutput.c
index ddfe3199d304f7811ff50c434bca7f47c2024d1b..d7ba61dc4d73e50cf919f8fcfe209d269a6d01e9 100644 (file)
@@ -864,13 +864,19 @@ void shade_color(ShadeInput *shi, ShadeResult *shr)
 {
        Material *ma= shi->mat;
 
-       if(ma->mode & (MA_VERTEXCOLP|MA_FACETEXTURE)) {
+       if(ma->mode & (MA_FACETEXTURE)) {
                shi->r= shi->vcol[0];
                shi->g= shi->vcol[1];
                shi->b= shi->vcol[2];
                if(ma->mode & (MA_FACETEXTURE_ALPHA))
                        shi->alpha= shi->vcol[3];
        }
+       else if(ma->mode & (MA_VERTEXCOLP)) {
+               float neg_alpha = 1.0f - shi->vcol[3];
+               shi->r= shi->r*neg_alpha + shi->vcol[0]*shi->vcol[3];
+               shi->g= shi->g*neg_alpha + shi->vcol[1]*shi->vcol[3];
+               shi->b= shi->b*neg_alpha + shi->vcol[2]*shi->vcol[3];
+       }
        
        if(ma->texco)
                do_material_tex(shi);
@@ -1655,12 +1661,18 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
        
        /* material color itself */
        if(passflag & (SCE_PASS_COMBINED|SCE_PASS_RGBA)) {
-               if(ma->mode & (MA_VERTEXCOLP|MA_FACETEXTURE)) {
+               if(ma->mode & (MA_FACETEXTURE)) {
                        shi->r= shi->vcol[0];
                        shi->g= shi->vcol[1];
                        shi->b= shi->vcol[2];
                        if(ma->mode & (MA_FACETEXTURE_ALPHA))
-                               shi->alpha= (shi->mode & MA_TRANSP) ? shi->vcol[3] : 1.0f;
+                               shi->alpha= shi->vcol[3];
+               }
+               else if(ma->mode & (MA_VERTEXCOLP)) {
+                       float neg_alpha = 1.0f - shi->vcol[3];
+                       shi->r= shi->r*neg_alpha + shi->vcol[0]*shi->vcol[3];
+                       shi->g= shi->g*neg_alpha + shi->vcol[1]*shi->vcol[3];
+                       shi->b= shi->b*neg_alpha + shi->vcol[2]*shi->vcol[3];
                }
                if(ma->texco){
                        do_material_tex(shi);