Comments
[blender.git] / source / blender / render / intern / source / shadeoutput.c
index 4f41f2729a147272688e69575befbed96b21ba49..427d0eeed11fa4de58f249e6051935dae4d12c99 100644 (file)
@@ -181,7 +181,8 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens)
        double a, b, c, disc, nray[3], npos[3];
        double t0, t1 = 0.0f, t2= 0.0f, t3;
        float p1[3], p2[3], ladist, maxz = 0.0f, maxy = 0.0f, haint;
-       int cuts, do_clip = TRUE, use_yco = FALSE;
+       int cuts;
+       bool do_clip = true, use_yco = false;
 
        *intens= 0.0f;
        haint= lar->haint;
@@ -217,7 +218,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens)
 
        /* rotate maxz */
        if (shi->co[2]==0.0f) {
-               do_clip = FALSE;  /* for when halo at sky */
+               do_clip = false;  /* for when halo at sky */
        }
        else {
                p1[0]= shi->co[0]-lar->co[0];
@@ -229,7 +230,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens)
                maxy= lar->imat[0][1]*p1[0]+lar->imat[1][1]*p1[1]+lar->imat[2][1]*p1[2];
 
                if (fabs(nray[2]) < FLT_EPSILON) {
-                       use_yco = TRUE;
+                       use_yco = true;
                }
        }
        
@@ -285,7 +286,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens)
                if (ok1==0 && ok2==0) return;
                
                /* intersction point with -ladist, the bottom of the cone */
-               if (use_yco == FALSE) {
+               if (use_yco == false) {
                        t3= ((double)(-ladist)-npos[2])/nray[2];
                                
                        /* de we have to replace one of the intersection points? */
@@ -319,7 +320,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens)
                
                /* calculate t0: is the maximum visible z (when halo is intersected by face) */ 
                if (do_clip) {
-                       if (use_yco == FALSE) t0 = ((double)maxz - npos[2]) / nray[2];
+                       if (use_yco == false) t0 = ((double)maxz - npos[2]) / nray[2];
                        else                  t0 = ((double)maxy - npos[1]) / nray[1];
 
                        if (t0 < t1) return;
@@ -1465,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;
                                        }
@@ -1703,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;
@@ -1720,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];