Fixes for SSS with render layers. Now in the preprocessing pass
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 24 Jan 2008 15:41:21 +0000 (15:41 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 24 Jan 2008 15:41:21 +0000 (15:41 +0000)
it uses flags from all render layers added together, not fully
correct yet, but it's not so easy to separate passes cleanly with
SSS.

source/blender/render/intern/source/rendercore.c
source/blender/render/intern/source/sss.c
source/blender/render/intern/source/zbuf.c

index 531594e2eced28d0fdca38b702ecdb76008575ca..220c06f1edefaa263ba2855e0d98fc760c2d8bfb 100644 (file)
@@ -1364,12 +1364,12 @@ void zbufshade_sss_tile(RenderPart *pa)
        ShadeSample ssamp;
        ZBufSSSHandle handle;
        RenderResult *rr= pa->result;
-       RenderLayer *rl= rr->layers.first;
+       RenderLayer *rl;
        VlakRen *vlr;
        Material *mat= re->sss_mat;
-       float (*co)[3], (*color)[3], *area, *fcol= rl->rectf;
+       float (*co)[3], (*color)[3], *area, *fcol;
        int x, y, seed, quad, totpoint, display = !(re->r.scemode & R_PREVIEWBUTS);
-       int *ro, *rz, *rp, *rbo, *rbz, *rbp;
+       int *ro, *rz, *rp, *rbo, *rbz, *rbp, lay;
 #if 0
        PixStr *ps;
        long *rs;
@@ -1394,13 +1394,32 @@ void zbufshade_sss_tile(RenderPart *pa)
        pa->rectbackz= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectbackz");
 #endif
 
+       /* setup shade sample with correct passes */
+       memset(&ssamp, 0, sizeof(ssamp));
+       shade_sample_initialize(&ssamp, pa, rr->layers.first);
+       ssamp.tot= 1;
+       
+       for(rl=rr->layers.first; rl; rl=rl->next) {
+               ssamp.shi[0].lay |= rl->lay;
+               ssamp.shi[0].layflag |= rl->layflag;
+               ssamp.shi[0].passflag |= rl->passflag;
+               ssamp.shi[0].combinedflag |= ~rl->pass_xor;
+       }
+
+       rl= rr->layers.first;
+       ssamp.shi[0].passflag |= SCE_PASS_RGBA|SCE_PASS_COMBINED;
+       ssamp.shi[0].combinedflag &= ~(SCE_PASS_SPEC);
+       lay= ssamp.shi[0].lay;
+
        /* create the pixelstrs to be used later */
-       zbuffer_sss(pa, rl->lay, &handle, addps_sss);
+       zbuffer_sss(pa, lay, &handle, addps_sss);
 
        if(handle.totps==0) {
                zbufshade_sss_free(pa);
                return;
        }
+       
+       fcol= rl->rectf;
 
        co= MEM_mallocN(sizeof(float)*3*handle.totps, "SSSCo");
        color= MEM_mallocN(sizeof(float)*3*handle.totps, "SSSColor");
@@ -1412,14 +1431,6 @@ void zbufshade_sss_tile(RenderPart *pa)
                ISB_create(pa, NULL);
 #endif
 
-       /* setup shade sample with correct passes */
-       memset(&ssamp, 0, sizeof(ssamp));
-       shade_sample_initialize(&ssamp, pa, rl);
-       ssamp.shi[0].passflag= SCE_PASS_DIFFUSE|SCE_PASS_AO|SCE_PASS_RADIO;
-       ssamp.shi[0].passflag |= SCE_PASS_RGBA;
-       ssamp.shi[0].combinedflag= ~(SCE_PASS_SPEC);
-       ssamp.tot= 1;
-
        if(display) {
                /* initialize scanline updates for main thread */
                rr->renrect.ymin= 0;
index 09a3b9ef66de12afba1b7c17f9a8286fe3a453a8..88333265a8445af207a544e30a08c8adef1a1cbc 100644 (file)
@@ -860,13 +860,13 @@ static void sss_create_tree_mat(Render *re, Material *mat)
           setting them back, maybe we need to create our own Render? */
 
        /* do SSS preprocessing render */
-       layers= re->r.layers;
+       rr= re->result;
+       layers= rr->layers;
        osa= re->osa;
        osaflag= re->r.mode & R_OSA;
        partsdone= re->i.partsdone;
-       rr= re->result;
 
-       re->r.layers.first= re->r.layers.last= NULL;
+       rr->layers.first= rr->layers.last= NULL;
        re->osa= 0;
        re->r.mode &= ~R_OSA;
        re->sss_points= &points;
@@ -881,7 +881,7 @@ static void sss_create_tree_mat(Render *re, Material *mat)
        re->i.partsdone= partsdone;
        re->sss_mat= NULL;
        re->sss_points= NULL;
-       re->r.layers= layers;
+       rr->layers= layers;
        re->osa= osa;
        if (osaflag) re->r.mode |= R_OSA;
 
index 3198b77181541b417b601b89c1b0f03d38441675..06bfc3b25f6dfb7ce6aa99752baf221056fd1e3a 100644 (file)
@@ -1993,6 +1993,9 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*,
        for(i=0, obi=R.instancetable.first; obi; i++, obi=obi->next) {
                obr= obi->obr;
 
+               if(!all_z && !(obr->lay & lay))
+                       continue;
+
                if(obi->flag & R_TRANSFORMED)
                        zbuf_make_winmat(&R, obi->mat, winmat);
                else
@@ -2274,6 +2277,8 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int
 
                if(obr->ob==re->excludeob)
                        continue;
+               else if(!(obr->lay & lay))
+                       continue;
 
                if(obi->flag & R_TRANSFORMED)
                        Mat4MulMat4(obwinmat, obi->mat, winmat);
@@ -2497,6 +2502,9 @@ void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(vo
        for(i=0, obi=R.instancetable.first; obi; i++, obi=obi->next) {
                obr= obi->obr;
 
+               if(!(obr->lay & lay))
+                       continue;
+
                if(obi->flag & R_TRANSFORMED)
                        zbuf_make_winmat(&R, obi->mat, winmat);
                else
@@ -3198,6 +3206,9 @@ static int zbuffer_abuf(RenderPart *pa, APixstr *APixbuf, ListBase *apsmbase, un
        for(i=0, obi=R.instancetable.first; obi; i++, obi=obi->next) {
                obr= obi->obr;
 
+               if(!(obr->lay & lay))
+                       continue;
+
                if(obi->flag & R_TRANSFORMED)
                        zbuf_make_winmat(&R, obi->mat, winmat);
                else