Fix T41408: Render layer pass bug, second attempt
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 13 Aug 2014 16:43:11 +0000 (22:43 +0600)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 13 Aug 2014 16:45:21 +0000 (22:45 +0600)
Missed some passes in the previous commit. Now seems all the passes
are covered, at least with my understanding of the things.

There're some weird things going around with the refraction pass,
but that is caused by some other issue in the code. Would rather
call it a TODO for now.

source/blender/render/intern/source/shadeoutput.c

index 4c67a320dd018873e811c9bd45d190aa98f4d6f1..5fdd615ed5d5dbb4c065e597817aa4571ca7e137 100644 (file)
@@ -1706,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 tryign 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;
@@ -1723,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|SCE_PASS_DIFFUSE|SCE_PASS_SPEC)) {
+       if (passflag & color_passes) {
                if (ma->mode & (MA_FACETEXTURE)) {
                        shi->r= shi->vcol[0];
                        shi->g= shi->vcol[1];