Comments
[blender.git] / source / blender / render / intern / source / shadeoutput.c
index cc781c863a09a6f859d73c6ef7e89ba6d0bcac97..427d0eeed11fa4de58f249e6051935dae4d12c99 100644 (file)
@@ -1466,9 +1466,11 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int
                                                shr->shad[1] -= shadfac[3]*shi->g*(1.0f-lashdw[1]);
                                                shr->shad[2] -= shadfac[3]*shi->b*(1.0f-lashdw[2]);
                                                
-                                               shr->spec[0] -= shadfac[3]*shi->specr*(1.0f-lashdw[0]);
-                                               shr->spec[1] -= shadfac[3]*shi->specg*(1.0f-lashdw[1]);
-                                               shr->spec[2] -= shadfac[3]*shi->specb*(1.0f-lashdw[2]);
+                                               if (!(lar->mode & LA_NO_SPEC)) {
+                                                       shr->spec[0] -= shadfac[3]*shi->specr*(1.0f-lashdw[0]);
+                                                       shr->spec[1] -= shadfac[3]*shi->specg*(1.0f-lashdw[1]);
+                                                       shr->spec[2] -= shadfac[3]*shi->specb*(1.0f-lashdw[2]);
+                                               }
                                                
                                                return;
                                        }
@@ -1704,9 +1706,19 @@ static void wrld_exposure_correct(float diff[3])
 
 void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
 {
+       /* Passes which might need to know material color.
+        *
+        * It seems to be faster to just calculate material color
+        * even if the pass doesn't really need it than trying to
+        * figure out whether color is really needed or not.
+        */
+       const int color_passes =
+               SCE_PASS_COMBINED | SCE_PASS_RGBA | SCE_PASS_DIFFUSE | SCE_PASS_SPEC |
+               SCE_PASS_REFLECT | SCE_PASS_NORMAL | SCE_PASS_REFRACT | SCE_PASS_EMIT;
+
        Material *ma= shi->mat;
        int passflag= shi->passflag;
-       
+
        memset(shr, 0, sizeof(ShadeResult));
        
        if (!(shi->mode & MA_TRANSP)) shi->alpha = 1.0f;
@@ -1721,7 +1733,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
        shi->refcol[0]= shi->refcol[1]= shi->refcol[2]= shi->refcol[3]= 0.0f;
        
        /* material color itself */
-       if (passflag & (SCE_PASS_COMBINED|SCE_PASS_RGBA)) {
+       if (passflag & color_passes) {
                if (ma->mode & (MA_FACETEXTURE)) {
                        shi->r= shi->vcol[0];
                        shi->g= shi->vcol[1];